SlideShare a Scribd company logo
Splint the C code static checker

      Pedro Pereira             Ulisses Costa

     Formal Methods in Software Engineering


                    May 28, 2009




 Pedro Pereira, Ulisses Costa   Splint the C code static checker
Sum´rio
   a

 1   Introduction

 2   Unused variables

 3   Types

 4   Memory management

 5   Control Flow

 6   Buffer sizes

 7   The Ultimate Test: wu-ftpd

 8   Pros and Cons

 9   Conclusions




                        Pedro Pereira, Ulisses Costa   Splint the C code static checker
Lint for detecting anomalies in C programs



  Statically checking C programs

      Unused declarations
      Type inconsistencies
      Use before definition
      Unreachable code
      Ignored return values
      Execution paths with no return
      Infinite loops




                Pedro Pereira, Ulisses Costa   Splint the C code static checker
Splint




         Specification Lint and Secure Programming Lint
         Annotations
             Functions
             Variables
             Parameters
             Types




                  Pedro Pereira, Ulisses Costa   Splint the C code static checker
Sum´rio
   a

 1   Introduction

 2   Unused variables

 3   Types

 4   Memory management

 5   Control Flow

 6   Buffer sizes

 7   The Ultimate Test: wu-ftpd

 8   Pros and Cons

 9   Conclusions




                        Pedro Pereira, Ulisses Costa   Splint the C code static checker
Unused variables



      Splint detects instances where the value of a location is used
      before it is defined.
      Annotations can be used to describe what storage must be
      defined and what storage may be undefined at interface
      points.
      All storage reachable is defined before and after a function
      call.
          global variable
          parameter to a function
          function return value




                Pedro Pereira, Ulisses Costa   Splint the C code static checker
Undefined Parameters

       Sometimes, function parameters or return values are expected to
       reference undefined or partially defined storage.
             out annotation denotes a pointer to storage that may be
             undefined
             in annotation can be used to denote a parameter that must
             be completely defined
 1   extern void setVal (/*@out@*/ int * x ) ;
 2   extern int getVal (/*@in@*/ int * x ) ;
 3   extern int mysteryVal ( int * x ) ;
                                                          > splint usedef . c
 4
                                                          usedef . c :7: Value * x used before
 5   int dumbfunc (/*@out@*/ int *x , int i ) {                definition
 6      if ( i > 3)                                       usedef . c :9: Passed storage x not
 7         return * x ;                                        completely defined
 8      else if ( i > 1)                                                (* x is undefined ) : getVal ( x )
 9         return getVal ( x ) ;                          usedef . c :11: Passed storage x not
10      else if ( i == 0)                                      completely defined
11         return mysteryVal ( x ) ;                                    (* x is undefined ) : mysteryVal
12      else {                                                                 (x)
13         setVal ( x ) ;                                 Finished checking --- 3 code warnings
14         return * x ;
15      }
16   }



                           Pedro Pereira, Ulisses Costa   Splint the C code static checker
Sum´rio
   a

 1   Introduction

 2   Unused variables

 3   Types

 4   Memory management

 5   Control Flow

 6   Buffer sizes

 7   The Ultimate Test: wu-ftpd

 8   Pros and Cons

 9   Conclusions




                        Pedro Pereira, Ulisses Costa   Splint the C code static checker
Types

            Strong type checking often reveals programming
        errors. Splint can check primitive C types more strictly
        and flexibly than typical compilers.

  Built in C Types
  Splint supports stricter checking of built-in C types. The char and
  enum types can be checked as distinct types, and the different
  numeric types can be type-checked strictly.

  Characters
  The primitive char type can be type-checked as a distinct type. If
  char is used as a distinct type, common errors involving assigning
  ints to chars are detected.
  If charint is on (+), char types are indistinguishable from ints.

                  Pedro Pereira, Ulisses Costa   Splint the C code static checker
Types - Enums




  An error is reported if:
       a value that is not an enumerator member is assigned to the
       enum type
       if an enum type is used as an operand to an arithmetic
       operator
  If the enumint flag is on, enum and int types may be used
  interchangeably.




                  Pedro Pereira, Ulisses Costa   Splint the C code static checker
Sum´rio
   a

 1   Introduction

 2   Unused variables

 3   Types

 4   Memory management

 5   Control Flow

 6   Buffer sizes

 7   The Ultimate Test: wu-ftpd

 8   Pros and Cons

 9   Conclusions




                        Pedro Pereira, Ulisses Costa   Splint the C code static checker
Memory management


          About half the bugs in typical C programs can be
      attributed to memory management problems.


      Some only appear sporadically
      And some may only be apparent when compiled on a different
      platform

  Splint detects many memory management errors at compile time
       Using storage that may have been deallocated
      Memory leaks
      Returning a pointer to stack-allocated storage



                Pedro Pereira, Ulisses Costa   Splint the C code static checker
Memory management - Memory Model



     An object is a typed region of storage;
     Some objects use a fixed amount of storage (that is allocated
     and deallocated by the compiler);
     Other objects use dynamic memory storage that must be
     managed by the program.

     Storage is undefined if it has not been assigned a value
     and defined after it has been assigned a value.
     An object is completely defined if all storage that may be
     reached from it is defined.




               Pedro Pereira, Ulisses Costa   Splint the C code static checker
Memory management - Memory Model (cont.)




  What storage is reachable from an object depends on the type and
  value of the object.

  Example
  If p is a pointer to a structure, p is completely defined if the value
  of p is NULL, or if every field of the structure p points to is
  completely defined.




                 Pedro Pereira, Ulisses Costa   Splint the C code static checker
Memory management - Memory Model (cont.)

  Left side of an assignment
       When an expression is used as the left side of an assignment
       we say it is an lvalue;
      Its location in memory is used, but not its value;
      Undefined storage may be used as an lvalue since only its
      location is needed.

  Right side of an assignment
      When storage is used in any other way:
           on the right side of an assignment;
           as an operand to a primitive operator;
           as a function parameter.
      we say it is used as an rvalue;
      It is an anomaly to use undefined storage as an rvalue.

                 Pedro Pereira, Ulisses Costa   Splint the C code static checker
Memory management - Deallocation Errors

        Deallocating storage when there are other live references to
        the same storage
        Failing to deallocate storage before the last reference to it is
        lost

    Solution
         Obligation to release storage
        This obligation is attached to the reference to which the
        storage is assigned

        The only annotation is used to indicate that a reference is the
        only pointer to the object it points to:
1   /* @only@ */ /* @null@ */ void * malloc ( size_t size ) ;



                   Pedro Pereira, Ulisses Costa   Splint the C code static checker
Memory management - Memory Leaks



                                                     > splint only . c
1   extern /* @only@ */ int * glob ;                 only . c :4: Only storage glob ( type int *)
2                                                             not released
                                                                  before assignment : glob = y
3   /* @only@ */ int * f ( /* @only@ */                only . c :1: Storage glob becomes only
         int *x , int *y , int * z ) {               only . c :4: Implicitly temp storage y
4       int * m = ( int *) malloc (                         assigned to only :
                                                                  glob = y
            sizeof ( int ) ) ;                       only . c :6: Dereference of possibly null
5       glob = y ;      // Memory leak                      pointer m : * m
                                                       only . c :8: Storage m may become null
6       free ( x ) ;                                 only . c :6: Variable x used after being
7       *m = *x;        // Use after                        released
            free                                       only . c :5: Storage x released
                                                     only . c :7: Implicitly temp storage z
8       return z ;      // Memory leak                      returned as only : z
              detected                               only . c :7: Fresh storage m not released
9   }                                                       before return
                                                       only . c :3: Fresh storage m allocated




                      Pedro Pereira, Ulisses Costa   Splint the C code static checker
Memory management - Stack References
             A memory error occurs if a pointer into stack is live after the
             function returns
             Splint detects errors involving stack references exported from
             a function through return values or assignments to references
             reachable from global variables or actual parameters

         No annotations are needed to detect stack reference errors. It is
         clear from declarations if storage is allocated on the function stack.

1    int * glob ;                                          > splint stack . c
2                                                          stack . c :9: Stack - allocated storage & loc
3    int * f ( int ** x ) {                                      reachable
                                                                        from return value : & loc
4       int sa [2] = { 0 , 1 };                            stack . c :9: Stack - allocated storage * x
5       int loc = 3;                                             reachable from
6                                                                       parameter x
                                                             stack . c :8: Storage * x becomes stack
7         glob = & loc ;                                   stack . c :9: Stack - allocated storage glob
8         * x = & sa [0];                                        reachable
9         return & loc ;                                                from global glob
                                                             stack . c :7: Storage glob becomes stack
10   }

                            Pedro Pereira, Ulisses Costa   Splint the C code static checker
Sum´rio
   a

 1   Introduction

 2   Unused variables

 3   Types

 4   Memory management

 5   Control Flow

 6   Buffer sizes

 7   The Ultimate Test: wu-ftpd

 8   Pros and Cons

 9   Conclusions




                        Pedro Pereira, Ulisses Costa   Splint the C code static checker
Control Flow - Execution




      Many of these checks are possible because of the extra
      information that is known in annotations
      To avoid spurious errors it is important to know something
      about the behaviour of called functions
      Without additional information Splint assumes that all
      functions return and execution continues normally




                Pedro Pereira, Ulisses Costa   Splint the C code static checker
Control Flow - Execution (cont.)



    noreturn annotation is used to denote a function that never
    returns.

1   extern /* @noreturn@ */ void fatalerror ( char * s ) ;


    Problem!
    We also have maynoreturn and alwaysreturns annotations, but
    Splint must assume that a function returns normally when
    checking the code and doesn’t verify if a function really returns.




                   Pedro Pereira, Ulisses Costa   Splint the C code static checker
Control Flow - Execution (cont.)



    To describe non-returning functions the noreturnwhentrue and
    noreturnwhenfalse mean that a function never returns if the first
    argument is true or false.
1   /* @ n o r e t u r n w h e n f a l s e @ */ void assert ( /* @sef@ */ bool /* @alt
          int@ */ pred ) ;


         The sef annotation denotes a parameter as side effect free
         The alt int indicate that it may be either a Boolean or an
         integer




                       Pedro Pereira, Ulisses Costa   Splint the C code static checker
Control Flow - Undefined Behavior




          The order which side effects take place in C is not
      entirely defined by the code.


  Sequence point
      a function call (after the arguments have been evaluated)
      at the end of a if, while, for or do statement
      a &&, || and ?




                   Pedro Pereira, Ulisses Costa   Splint the C code static checker
Control Flow - Undefined Behavior (cont.)


                                                    > splint order . c + evalorderuncon
                                                    order . c :5: Expression has undefined
1    extern int glob ;                                    behavior ( value of
                                                    right operand modified by left operand ) :
2    extern int mystery ( void ) ;                          x ++ * x
3    extern int modglob ( void ) /*                 order . c :6: Expression has undefined
          @globals glob@ */ /*                            behavior ( left operand
                                                    uses i , modified by right operand ) : y [ i ]
          @modifies glob@ */ ;                              = i ++
4    int f ( int x , int y []) {                    order . c :7: Expression has undefined
5       int i = x ++ * x ;                                behavior ( value of
                                                    right operand modified by left operand ) :
6       y [ i ] = i ++;                             modglob () * glob
7       i += modglob () * glob ;                    order . c :8: Expression has undefined
8       i += mystery () * glob ;                          behavior
                                                    ( unconstrained function mystery used in
9       return i ;                                        left operand
10   }                                              may set global variable glob used in
                                                          right operand ) :
                                                    mystery () * glob




                     Pedro Pereira, Ulisses Costa   Splint the C code static checker
Control Flow - Likely Infinite Loops


       Splint reports an error if it detects a loop that appears to be
       inifinite. An error is reported for a loop that does not modify any
       value used in its condition test inside the body of the loop or in the
       condition test itself.
1    extern int glob1 , glob2 ;
2    extern int f ( void ) /* @globals
          glob1@ */ /* @modifies                      > splint loop . c + infloopsuncon
                                                      loop . c :7: Suspected infinite loop . No
         nothing@ */ ;                                       value used in
3    extern void g ( void ) /*                        loop test (x , glob1 ) is modified by test
                                                               or loop
         @modifies glob2@ */ ;                        body .
4    extern void h ( void ) ;                         loop . c :8: Suspected infinite loop . No
5                                                            condition
                                                      values modified . Modification possible
6    void upto ( int x ) {                                   through
7       while ( x > f () ) g () ;                     unconstrained calls : h
8       while ( f () < 3) h () ;
9    }




                       Pedro Pereira, Ulisses Costa   Splint the C code static checker
Control Flow - Switches

        Splint detects case statements with code that may fall through to
        the next case. The casebreak flag controls reporting of fall
        through cases. The keyword fallthrough explicitly indicates that
        execution falls through to this case.
1     typedef enum {
2        YES , NO , DEFINITELY ,
3        PROBABLY , MAYBE } ynm ;
4
5     void decide ( ynm y ) {
6        switch ( y ) {
                                                        > splint switch . c
7           case PROBABLY :                             switch . c :9: Fall through case ( no
8           case NO : printf ( quot; No ! quot; ) ;                  preceding break )
                                                        switch . c :12: Missing case in switch :
9           case MAYBE : printf ( quot;                          DEFINITELY
                 Maybe quot; ) ;
10          /* @fallthrough@ */
11          case YES : printf ( quot; Yes ! quot;
                 );
12       }
13    }



                         Pedro Pereira, Ulisses Costa   Splint the C code static checker
Control Flow - Conclusion




  But Splint has more!
      Deep Breaks
      Complete Logic




                Pedro Pereira, Ulisses Costa   Splint the C code static checker
Sum´rio
   a

 1   Introduction

 2   Unused variables

 3   Types

 4   Memory management

 5   Control Flow

 6   Buffer sizes

 7   The Ultimate Test: wu-ftpd

 8   Pros and Cons

 9   Conclusions




                        Pedro Pereira, Ulisses Costa   Splint the C code static checker
Buffer sizes




    1   Buffer overflow errors are a particularly dangerous type of bug
        in C
    2   They are responsible for half of all security attacks
    3   C does not perform runtime bound checking (for performance
        reasons)
    4   Attackers can exploit program bugs to gain full access to a
        machine




                   Pedro Pereira, Ulisses Costa   Splint the C code static checker
Buffer sizes - Checking access

  Splint models blocks of memory using two properties:
  maxSet
  maxSet(b) denotes the highest address beyond b that can be
  safely used as lvalue, for instance:
  char buffer[MAXSIZE] we have maxSet(buffer ) = MAXSIZE − 1

  maxRead
  maxRead(b) denotes the highest index of a buffer that can be
  safely used as rvalue.

      When a buffer is accessed as an lvalue, Splint generates a
      precondition constraint involving the maxSet property
      When a buffer is accessed as an rvalue, Splint generates a
      precondition constraint involving the maxRead property

                Pedro Pereira, Ulisses Costa   Splint the C code static checker
Buffer sizes - Annotating Buffer Sizes




    1   Function declarations may include requires and ensures
        clauses to specify assumptions about buffer sizes for function
        preconditions
    2   When a function with requires clause is called, the call site
        must be checked to satisfy the constraints implied by requires
    3   If the +checkpost is set, Splint warns if it cannot verify that
        a function implementation satisfies its declared postconditions




                  Pedro Pereira, Ulisses Costa   Splint the C code static checker
Buffer sizes - Annotating Buffer Sizes (cont.)




1   void /* @alt char * @ */ strcpy
2   ( /* @unique@ */ /* @out@ */ /* @returned@ */ char * s1 , char * s2 )
3   /* @modifies * s1@ */
4   /* @requires maxSet ( s1 ) >= maxRead ( s2 ) @ */
5   /* @ensures maxRead ( s1 ) == maxRead ( s2 ) @ */ ;




                    Pedro Pereira, Ulisses Costa   Splint the C code static checker
Buffer sizes - Annotating Buffer Sizes (cont.)




1   void /* @alt char * @ */ strncpy
2   ( /* @unique@ */ /* @out@ */ /* @returned@ */ char * s1 , char * s2 ,
3   size_t n )
4   /* @modifies * s1@ */
5   /* @requires maxSet ( s1 ) >= ( n - 1 ) ; @ */
6   /* @ensures maxRead ( s2 ) >= maxRead ( s1 ) / maxRead ( s1 ) <= n ;
          @ */ ;




                   Pedro Pereira, Ulisses Costa   Splint the C code static checker
Buffer sizes - Warnings



           Bound checking is more complex than other checks done by
           Splint
           So, memory bound warnings contain extensive information
           about the unresolved constraint
                                                    setChar . c :5:4: Likely out - of - bounds
                                                          store :
                                                    buf [10]
1    int buf [10];                                  Unable to resolve constraint : requires 9
2    buf [10] = 3;                                         >= 10
                                                    needed to satisfy precondition : requires
                                                           maxSet ( buf @ setChar . c :5:4) >= 10




                     Pedro Pereira, Ulisses Costa   Splint the C code static checker
Buffer sizes - Warnings (cont.)



                                                     > splint bounds . c + bounds +
                                                          showconstraintlocation
                                                     bounds . c :5: Possible out - of - bounds store
                                                          :
1    void updateEnv ( char * str ) {                 strcpy ( str , tmp )
2       char * tmp ;                                 Unable to resolve constraint :
                                                     requires maxSet ( str @ bounds . c :5) >=
3       tmp = getenv ( quot; MYENV quot; ) ;                 maxRead ( getenv (quot; MYENV quot;) @ bounds . c :3)
4       if ( tmp != NULL )                           needed to satisfy precondition :
5          strcpy ( str , tmp ) ;                    requires maxSet ( str @ bounds . c :5) >=
                                                     maxRead ( tmp @ bounds . c :5)
6    }                                               derived from strcpy precondition :
                                                          requires
                                                     maxSet ( < parameter 1 >) >=
                                                     maxRead ( < parameter 2 >)




                      Pedro Pereira, Ulisses Costa   Splint the C code static checker
Sum´rio
   a

 1   Introduction

 2   Unused variables

 3   Types

 4   Memory management

 5   Control Flow

 6   Buffer sizes

 7   The Ultimate Test: wu-ftpd

 8   Pros and Cons

 9   Conclusions




                        Pedro Pereira, Ulisses Costa   Splint the C code static checker
The Ultimate Test: wu-ftpd




     wu-ftpd version 2.5.0
     20.000 lines of code
     Took less than four seconds to check all of wu-ftpd on a
     1.2-GHz Athlon machine
     Splint detected the known flaws as well as finding some
     previously unknown flaws (!)




               Pedro Pereira, Ulisses Costa   Splint the C code static checker
The Ultimate Test: wu-ftpd (cont.)




      Running Splint on wu-ftpd without adding annotations
      produced 166 warnings for potential out-of-bounds writes
      After adding 66 annotations, it produced 101 warnings: 25 of
      these indicated real problems and 76 were false



                Pedro Pereira, Ulisses Costa   Splint the C code static checker
Sum´rio
   a

 1   Introduction

 2   Unused variables

 3   Types

 4   Memory management

 5   Control Flow

 6   Buffer sizes

 7   The Ultimate Test: wu-ftpd

 8   Pros and Cons

 9   Conclusions




                        Pedro Pereira, Ulisses Costa   Splint the C code static checker
Pros and Cons


  Pros
         Lightweight static analysis detects software vulnerabilities
         Splint definately improves code quality
         Suitable for real programs...

  Cons
      . . . although it produces more warning messages that lead to
      confusion
         It won’t eliminate all security risks
         Hasn’t been developed since 2007, they need new volunteers




                    Pedro Pereira, Ulisses Costa   Splint the C code static checker
Sum´rio
   a

 1   Introduction

 2   Unused variables

 3   Types

 4   Memory management

 5   Control Flow

 6   Buffer sizes

 7   The Ultimate Test: wu-ftpd

 8   Pros and Cons

 9   Conclusions




                        Pedro Pereira, Ulisses Costa   Splint the C code static checker
Conclusions




     No tool will eliminate all security risks
     Lightweight static analysis tools (Splint) play an important
     role in identifying security vulnerabilities




                Pedro Pereira, Ulisses Costa   Splint the C code static checker
Questions




                                           ?




            Pedro Pereira, Ulisses Costa       Splint the C code static checker

More Related Content

What's hot

Formatted input and output
Formatted input and outputFormatted input and output
Formatted input and output
Online
 
emc++ chapter32
emc++ chapter32emc++ chapter32
emc++ chapter32
Tatsuki SHIMIZU
 
Smart Pointers in C++
Smart Pointers in C++Smart Pointers in C++
Smart Pointers in C++
Francesco Casalegno
 
[嵌入式系統] MCS-51 實驗 - 使用 IAR (1)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (1)[嵌入式系統] MCS-51 實驗 - 使用 IAR (1)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (1)
Simen Li
 
Coordinazione n
Coordinazione nCoordinazione n
Coordinazione nimartini
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
Mauryasuraj98
 
Function C programming
Function C programmingFunction C programming
Function C programming
Appili Vamsi Krishna
 
Dynamic memory Allocation in c language
Dynamic memory Allocation in c languageDynamic memory Allocation in c language
Dynamic memory Allocation in c language
kiran Patel
 
Function in c program
Function in c programFunction in c program
Function in c program
umesh patil
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
Viji B
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
sai tarlekar
 
Structure c
Structure cStructure c
Structure c
thirumalaikumar3
 
CNS UNIT-II.pptx
CNS UNIT-II.pptxCNS UNIT-II.pptx
CNS UNIT-II.pptx
nandan543979
 
Effective Modern C++ Item 9 and 10
Effective Modern C++ Item 9 and 10Effective Modern C++ Item 9 and 10
Effective Modern C++ Item 9 and 10
uchan_nos
 
C++11: Rvalue References, Move Semantics, Perfect Forwarding
C++11: Rvalue References, Move Semantics, Perfect ForwardingC++11: Rvalue References, Move Semantics, Perfect Forwarding
C++11: Rvalue References, Move Semantics, Perfect Forwarding
Francesco Casalegno
 
Address/Thread/Memory Sanitizer
Address/Thread/Memory SanitizerAddress/Thread/Memory Sanitizer
Address/Thread/Memory Sanitizer
Platonov Sergey
 
Functional microscope - Lenses in C++
Functional microscope - Lenses in C++Functional microscope - Lenses in C++
Functional microscope - Lenses in C++
Alexander Granin
 

What's hot (20)

Formatted input and output
Formatted input and outputFormatted input and output
Formatted input and output
 
emc++ chapter32
emc++ chapter32emc++ chapter32
emc++ chapter32
 
Smart Pointers in C++
Smart Pointers in C++Smart Pointers in C++
Smart Pointers in C++
 
[嵌入式系統] MCS-51 實驗 - 使用 IAR (1)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (1)[嵌入式系統] MCS-51 實驗 - 使用 IAR (1)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (1)
 
Coordinazione n
Coordinazione nCoordinazione n
Coordinazione n
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
 
Constructor
ConstructorConstructor
Constructor
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
Function
FunctionFunction
Function
 
Dynamic memory Allocation in c language
Dynamic memory Allocation in c languageDynamic memory Allocation in c language
Dynamic memory Allocation in c language
 
Function in c program
Function in c programFunction in c program
Function in c program
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Structure c
Structure cStructure c
Structure c
 
CNS UNIT-II.pptx
CNS UNIT-II.pptxCNS UNIT-II.pptx
CNS UNIT-II.pptx
 
5bit field
5bit field5bit field
5bit field
 
Effective Modern C++ Item 9 and 10
Effective Modern C++ Item 9 and 10Effective Modern C++ Item 9 and 10
Effective Modern C++ Item 9 and 10
 
C++11: Rvalue References, Move Semantics, Perfect Forwarding
C++11: Rvalue References, Move Semantics, Perfect ForwardingC++11: Rvalue References, Move Semantics, Perfect Forwarding
C++11: Rvalue References, Move Semantics, Perfect Forwarding
 
Address/Thread/Memory Sanitizer
Address/Thread/Memory SanitizerAddress/Thread/Memory Sanitizer
Address/Thread/Memory Sanitizer
 
Functional microscope - Lenses in C++
Functional microscope - Lenses in C++Functional microscope - Lenses in C++
Functional microscope - Lenses in C++
 

Viewers also liked

Correct sorting with Frama-C
Correct sorting with Frama-CCorrect sorting with Frama-C
Correct sorting with Frama-C
Ulisses Costa
 
GD::Graph - Graph Plotting Module
GD::Graph - Graph Plotting ModuleGD::Graph - Graph Plotting Module
GD::Graph - Graph Plotting ModuleUlisses Costa
 
Snort - capturar e dissecar o tráfego da rede
Snort - capturar e dissecar o tráfego da redeSnort - capturar e dissecar o tráfego da rede
Snort - capturar e dissecar o tráfego da redeUlisses Costa
 
Specification of SNOW 3G in Cryptol
Specification of SNOW 3G in CryptolSpecification of SNOW 3G in Cryptol
Specification of SNOW 3G in CryptolUlisses Costa
 
Code Review Tool Evaluation
Code Review Tool EvaluationCode Review Tool Evaluation
Code Review Tool Evaluation
Kate Semizhon
 
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded SoftwareBeyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Quantum Leaps, LLC
 

Viewers also liked (6)

Correct sorting with Frama-C
Correct sorting with Frama-CCorrect sorting with Frama-C
Correct sorting with Frama-C
 
GD::Graph - Graph Plotting Module
GD::Graph - Graph Plotting ModuleGD::Graph - Graph Plotting Module
GD::Graph - Graph Plotting Module
 
Snort - capturar e dissecar o tráfego da rede
Snort - capturar e dissecar o tráfego da redeSnort - capturar e dissecar o tráfego da rede
Snort - capturar e dissecar o tráfego da rede
 
Specification of SNOW 3G in Cryptol
Specification of SNOW 3G in CryptolSpecification of SNOW 3G in Cryptol
Specification of SNOW 3G in Cryptol
 
Code Review Tool Evaluation
Code Review Tool EvaluationCode Review Tool Evaluation
Code Review Tool Evaluation
 
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded SoftwareBeyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
 

Similar to Splint the C code static checker

Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2
ppd1961
 
Dynamic memory allocation in c++
Dynamic memory allocation in c++Dynamic memory allocation in c++
Dynamic memory allocation in c++Tech_MX
 
Valgrind
ValgrindValgrind
Valgrind
aidanshribman
 
C++ memory leak detection
C++ memory leak detectionC++ memory leak detection
C++ memory leak detection
Võ Hòa
 
(5) cpp dynamic memory_arrays_and_c-strings
(5) cpp dynamic memory_arrays_and_c-strings(5) cpp dynamic memory_arrays_and_c-strings
(5) cpp dynamic memory_arrays_and_c-strings
Nico Ludwig
 
C++tutorial
C++tutorialC++tutorial
C++tutorialdips17
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
Andrea Righi
 
Quiz 9
Quiz 9Quiz 9
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
Nitesh Bichwani
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectre
Kim Phillips
 
Secure Programming Practices in C++ (NDC Oslo 2018)
Secure Programming Practices in C++ (NDC Oslo 2018)Secure Programming Practices in C++ (NDC Oslo 2018)
Secure Programming Practices in C++ (NDC Oslo 2018)
Patricia Aas
 
Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]
ppd1961
 
A exception ekon16
A exception ekon16A exception ekon16
A exception ekon16
Max Kleiner
 
from java to c
from java to cfrom java to c
from java to c
Võ Hòa
 
grsecurity and PaX
grsecurity and PaXgrsecurity and PaX
grsecurity and PaX
Kernel TLV
 
Dynamic Memory Allocation in C
Dynamic Memory Allocation in CDynamic Memory Allocation in C
Dynamic Memory Allocation in C
Vijayananda Ratnam Ch
 
What has to be paid attention when reviewing code of the library you develop
What has to be paid attention when reviewing code of the library you developWhat has to be paid attention when reviewing code of the library you develop
What has to be paid attention when reviewing code of the library you develop
Andrey Karpov
 
C programming session10
C programming  session10C programming  session10
C programming session10
Keroles karam khalil
 

Similar to Splint the C code static checker (20)

Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2
 
Dynamic memory allocation in c++
Dynamic memory allocation in c++Dynamic memory allocation in c++
Dynamic memory allocation in c++
 
Valgrind
ValgrindValgrind
Valgrind
 
C++ memory leak detection
C++ memory leak detectionC++ memory leak detection
C++ memory leak detection
 
(5) cpp dynamic memory_arrays_and_c-strings
(5) cpp dynamic memory_arrays_and_c-strings(5) cpp dynamic memory_arrays_and_c-strings
(5) cpp dynamic memory_arrays_and_c-strings
 
C++tutorial
C++tutorialC++tutorial
C++tutorial
 
Introduction to c part -3
Introduction to c   part -3Introduction to c   part -3
Introduction to c part -3
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
 
Quiz 9
Quiz 9Quiz 9
Quiz 9
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectre
 
Secure Programming Practices in C++ (NDC Oslo 2018)
Secure Programming Practices in C++ (NDC Oslo 2018)Secure Programming Practices in C++ (NDC Oslo 2018)
Secure Programming Practices in C++ (NDC Oslo 2018)
 
Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]
 
A exception ekon16
A exception ekon16A exception ekon16
A exception ekon16
 
Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
 
from java to c
from java to cfrom java to c
from java to c
 
grsecurity and PaX
grsecurity and PaXgrsecurity and PaX
grsecurity and PaX
 
Dynamic Memory Allocation in C
Dynamic Memory Allocation in CDynamic Memory Allocation in C
Dynamic Memory Allocation in C
 
What has to be paid attention when reviewing code of the library you develop
What has to be paid attention when reviewing code of the library you developWhat has to be paid attention when reviewing code of the library you develop
What has to be paid attention when reviewing code of the library you develop
 
C programming session10
C programming  session10C programming  session10
C programming session10
 

More from Ulisses Costa

Automatic Test Generation for Space
Automatic Test Generation for SpaceAutomatic Test Generation for Space
Automatic Test Generation for Space
Ulisses Costa
 
Automatic Test Generation for Space
Automatic Test Generation for SpaceAutomatic Test Generation for Space
Automatic Test Generation for SpaceUlisses Costa
 
Static Code Analyzer - Part IV
Static Code Analyzer - Part IVStatic Code Analyzer - Part IV
Static Code Analyzer - Part IVUlisses Costa
 
Specifying and Implementing SNOW3G with Cryptol
Specifying and Implementing SNOW3G with CryptolSpecifying and Implementing SNOW3G with Cryptol
Specifying and Implementing SNOW3G with CryptolUlisses Costa
 
Static Code Analyzer - Part III
Static Code Analyzer - Part IIIStatic Code Analyzer - Part III
Static Code Analyzer - Part IIIUlisses Costa
 
Static Code Analyzer - Part II
Static Code Analyzer - Part IIStatic Code Analyzer - Part II
Static Code Analyzer - Part IIUlisses Costa
 
Static Code Analyzer - Part I
Static Code Analyzer - Part IStatic Code Analyzer - Part I
Static Code Analyzer - Part IUlisses Costa
 
logCesium01
logCesium01logCesium01
logCesium01
Ulisses Costa
 
Cesium Log ed2
Cesium Log ed2Cesium Log ed2
Cesium Log ed2
Ulisses Costa
 
Captura de Informação em Rede
Captura de Informação em RedeCaptura de Informação em Rede
Captura de Informação em RedeUlisses Costa
 
Cryptol experience
Cryptol experienceCryptol experience
Cryptol experience
Ulisses Costa
 
The Cryptol Epilogue: Swift and Bulletproof VHDL
The Cryptol Epilogue: Swift and Bulletproof VHDLThe Cryptol Epilogue: Swift and Bulletproof VHDL
The Cryptol Epilogue: Swift and Bulletproof VHDL
Ulisses Costa
 
Exploring the Cryptol Toolset
Exploring the Cryptol ToolsetExploring the Cryptol Toolset
Exploring the Cryptol Toolset
Ulisses Costa
 
LDAP em VDM++
LDAP em VDM++LDAP em VDM++
LDAP em VDM++
Ulisses Costa
 
Uso de Honeypots com Honeyd
Uso de Honeypots com HoneydUso de Honeypots com Honeyd
Uso de Honeypots com Honeyd
Ulisses Costa
 
Linux Instalation Party
Linux Instalation PartyLinux Instalation Party
Linux Instalation Party
Ulisses Costa
 
Workshop LaTeX
Workshop LaTeXWorkshop LaTeX
Workshop LaTeX
Ulisses Costa
 
Calculador Pointfree
Calculador PointfreeCalculador Pointfree
Calculador Pointfree
Ulisses Costa
 

More from Ulisses Costa (19)

Automatic Test Generation for Space
Automatic Test Generation for SpaceAutomatic Test Generation for Space
Automatic Test Generation for Space
 
Automatic Test Generation for Space
Automatic Test Generation for SpaceAutomatic Test Generation for Space
Automatic Test Generation for Space
 
Static Code Analyzer - Part IV
Static Code Analyzer - Part IVStatic Code Analyzer - Part IV
Static Code Analyzer - Part IV
 
Specifying and Implementing SNOW3G with Cryptol
Specifying and Implementing SNOW3G with CryptolSpecifying and Implementing SNOW3G with Cryptol
Specifying and Implementing SNOW3G with Cryptol
 
Static Code Analyzer - Part III
Static Code Analyzer - Part IIIStatic Code Analyzer - Part III
Static Code Analyzer - Part III
 
Static Code Analyzer - Part II
Static Code Analyzer - Part IIStatic Code Analyzer - Part II
Static Code Analyzer - Part II
 
Static Code Analyzer - Part I
Static Code Analyzer - Part IStatic Code Analyzer - Part I
Static Code Analyzer - Part I
 
logCesium01
logCesium01logCesium01
logCesium01
 
Cesium Log ed2
Cesium Log ed2Cesium Log ed2
Cesium Log ed2
 
Captura de Informação em Rede
Captura de Informação em RedeCaptura de Informação em Rede
Captura de Informação em Rede
 
Cryptol experience
Cryptol experienceCryptol experience
Cryptol experience
 
The Cryptol Epilogue: Swift and Bulletproof VHDL
The Cryptol Epilogue: Swift and Bulletproof VHDLThe Cryptol Epilogue: Swift and Bulletproof VHDL
The Cryptol Epilogue: Swift and Bulletproof VHDL
 
Exploring the Cryptol Toolset
Exploring the Cryptol ToolsetExploring the Cryptol Toolset
Exploring the Cryptol Toolset
 
LDAP em VDM++
LDAP em VDM++LDAP em VDM++
LDAP em VDM++
 
Uso de Honeypots com Honeyd
Uso de Honeypots com HoneydUso de Honeypots com Honeyd
Uso de Honeypots com Honeyd
 
Apresentacao JML
Apresentacao JMLApresentacao JML
Apresentacao JML
 
Linux Instalation Party
Linux Instalation PartyLinux Instalation Party
Linux Instalation Party
 
Workshop LaTeX
Workshop LaTeXWorkshop LaTeX
Workshop LaTeX
 
Calculador Pointfree
Calculador PointfreeCalculador Pointfree
Calculador Pointfree
 

Recently uploaded

GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

Splint the C code static checker

  • 1. Splint the C code static checker Pedro Pereira Ulisses Costa Formal Methods in Software Engineering May 28, 2009 Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 2. Sum´rio a 1 Introduction 2 Unused variables 3 Types 4 Memory management 5 Control Flow 6 Buffer sizes 7 The Ultimate Test: wu-ftpd 8 Pros and Cons 9 Conclusions Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 3. Lint for detecting anomalies in C programs Statically checking C programs Unused declarations Type inconsistencies Use before definition Unreachable code Ignored return values Execution paths with no return Infinite loops Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 4. Splint Specification Lint and Secure Programming Lint Annotations Functions Variables Parameters Types Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 5. Sum´rio a 1 Introduction 2 Unused variables 3 Types 4 Memory management 5 Control Flow 6 Buffer sizes 7 The Ultimate Test: wu-ftpd 8 Pros and Cons 9 Conclusions Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 6. Unused variables Splint detects instances where the value of a location is used before it is defined. Annotations can be used to describe what storage must be defined and what storage may be undefined at interface points. All storage reachable is defined before and after a function call. global variable parameter to a function function return value Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 7. Undefined Parameters Sometimes, function parameters or return values are expected to reference undefined or partially defined storage. out annotation denotes a pointer to storage that may be undefined in annotation can be used to denote a parameter that must be completely defined 1 extern void setVal (/*@out@*/ int * x ) ; 2 extern int getVal (/*@in@*/ int * x ) ; 3 extern int mysteryVal ( int * x ) ; > splint usedef . c 4 usedef . c :7: Value * x used before 5 int dumbfunc (/*@out@*/ int *x , int i ) { definition 6 if ( i > 3) usedef . c :9: Passed storage x not 7 return * x ; completely defined 8 else if ( i > 1) (* x is undefined ) : getVal ( x ) 9 return getVal ( x ) ; usedef . c :11: Passed storage x not 10 else if ( i == 0) completely defined 11 return mysteryVal ( x ) ; (* x is undefined ) : mysteryVal 12 else { (x) 13 setVal ( x ) ; Finished checking --- 3 code warnings 14 return * x ; 15 } 16 } Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 8. Sum´rio a 1 Introduction 2 Unused variables 3 Types 4 Memory management 5 Control Flow 6 Buffer sizes 7 The Ultimate Test: wu-ftpd 8 Pros and Cons 9 Conclusions Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 9. Types Strong type checking often reveals programming errors. Splint can check primitive C types more strictly and flexibly than typical compilers. Built in C Types Splint supports stricter checking of built-in C types. The char and enum types can be checked as distinct types, and the different numeric types can be type-checked strictly. Characters The primitive char type can be type-checked as a distinct type. If char is used as a distinct type, common errors involving assigning ints to chars are detected. If charint is on (+), char types are indistinguishable from ints. Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 10. Types - Enums An error is reported if: a value that is not an enumerator member is assigned to the enum type if an enum type is used as an operand to an arithmetic operator If the enumint flag is on, enum and int types may be used interchangeably. Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 11. Sum´rio a 1 Introduction 2 Unused variables 3 Types 4 Memory management 5 Control Flow 6 Buffer sizes 7 The Ultimate Test: wu-ftpd 8 Pros and Cons 9 Conclusions Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 12. Memory management About half the bugs in typical C programs can be attributed to memory management problems. Some only appear sporadically And some may only be apparent when compiled on a different platform Splint detects many memory management errors at compile time Using storage that may have been deallocated Memory leaks Returning a pointer to stack-allocated storage Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 13. Memory management - Memory Model An object is a typed region of storage; Some objects use a fixed amount of storage (that is allocated and deallocated by the compiler); Other objects use dynamic memory storage that must be managed by the program. Storage is undefined if it has not been assigned a value and defined after it has been assigned a value. An object is completely defined if all storage that may be reached from it is defined. Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 14. Memory management - Memory Model (cont.) What storage is reachable from an object depends on the type and value of the object. Example If p is a pointer to a structure, p is completely defined if the value of p is NULL, or if every field of the structure p points to is completely defined. Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 15. Memory management - Memory Model (cont.) Left side of an assignment When an expression is used as the left side of an assignment we say it is an lvalue; Its location in memory is used, but not its value; Undefined storage may be used as an lvalue since only its location is needed. Right side of an assignment When storage is used in any other way: on the right side of an assignment; as an operand to a primitive operator; as a function parameter. we say it is used as an rvalue; It is an anomaly to use undefined storage as an rvalue. Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 16. Memory management - Deallocation Errors Deallocating storage when there are other live references to the same storage Failing to deallocate storage before the last reference to it is lost Solution Obligation to release storage This obligation is attached to the reference to which the storage is assigned The only annotation is used to indicate that a reference is the only pointer to the object it points to: 1 /* @only@ */ /* @null@ */ void * malloc ( size_t size ) ; Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 17. Memory management - Memory Leaks > splint only . c 1 extern /* @only@ */ int * glob ; only . c :4: Only storage glob ( type int *) 2 not released before assignment : glob = y 3 /* @only@ */ int * f ( /* @only@ */ only . c :1: Storage glob becomes only int *x , int *y , int * z ) { only . c :4: Implicitly temp storage y 4 int * m = ( int *) malloc ( assigned to only : glob = y sizeof ( int ) ) ; only . c :6: Dereference of possibly null 5 glob = y ; // Memory leak pointer m : * m only . c :8: Storage m may become null 6 free ( x ) ; only . c :6: Variable x used after being 7 *m = *x; // Use after released free only . c :5: Storage x released only . c :7: Implicitly temp storage z 8 return z ; // Memory leak returned as only : z detected only . c :7: Fresh storage m not released 9 } before return only . c :3: Fresh storage m allocated Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 18. Memory management - Stack References A memory error occurs if a pointer into stack is live after the function returns Splint detects errors involving stack references exported from a function through return values or assignments to references reachable from global variables or actual parameters No annotations are needed to detect stack reference errors. It is clear from declarations if storage is allocated on the function stack. 1 int * glob ; > splint stack . c 2 stack . c :9: Stack - allocated storage & loc 3 int * f ( int ** x ) { reachable from return value : & loc 4 int sa [2] = { 0 , 1 }; stack . c :9: Stack - allocated storage * x 5 int loc = 3; reachable from 6 parameter x stack . c :8: Storage * x becomes stack 7 glob = & loc ; stack . c :9: Stack - allocated storage glob 8 * x = & sa [0]; reachable 9 return & loc ; from global glob stack . c :7: Storage glob becomes stack 10 } Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 19. Sum´rio a 1 Introduction 2 Unused variables 3 Types 4 Memory management 5 Control Flow 6 Buffer sizes 7 The Ultimate Test: wu-ftpd 8 Pros and Cons 9 Conclusions Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 20. Control Flow - Execution Many of these checks are possible because of the extra information that is known in annotations To avoid spurious errors it is important to know something about the behaviour of called functions Without additional information Splint assumes that all functions return and execution continues normally Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 21. Control Flow - Execution (cont.) noreturn annotation is used to denote a function that never returns. 1 extern /* @noreturn@ */ void fatalerror ( char * s ) ; Problem! We also have maynoreturn and alwaysreturns annotations, but Splint must assume that a function returns normally when checking the code and doesn’t verify if a function really returns. Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 22. Control Flow - Execution (cont.) To describe non-returning functions the noreturnwhentrue and noreturnwhenfalse mean that a function never returns if the first argument is true or false. 1 /* @ n o r e t u r n w h e n f a l s e @ */ void assert ( /* @sef@ */ bool /* @alt int@ */ pred ) ; The sef annotation denotes a parameter as side effect free The alt int indicate that it may be either a Boolean or an integer Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 23. Control Flow - Undefined Behavior The order which side effects take place in C is not entirely defined by the code. Sequence point a function call (after the arguments have been evaluated) at the end of a if, while, for or do statement a &&, || and ? Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 24. Control Flow - Undefined Behavior (cont.) > splint order . c + evalorderuncon order . c :5: Expression has undefined 1 extern int glob ; behavior ( value of right operand modified by left operand ) : 2 extern int mystery ( void ) ; x ++ * x 3 extern int modglob ( void ) /* order . c :6: Expression has undefined @globals glob@ */ /* behavior ( left operand uses i , modified by right operand ) : y [ i ] @modifies glob@ */ ; = i ++ 4 int f ( int x , int y []) { order . c :7: Expression has undefined 5 int i = x ++ * x ; behavior ( value of right operand modified by left operand ) : 6 y [ i ] = i ++; modglob () * glob 7 i += modglob () * glob ; order . c :8: Expression has undefined 8 i += mystery () * glob ; behavior ( unconstrained function mystery used in 9 return i ; left operand 10 } may set global variable glob used in right operand ) : mystery () * glob Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 25. Control Flow - Likely Infinite Loops Splint reports an error if it detects a loop that appears to be inifinite. An error is reported for a loop that does not modify any value used in its condition test inside the body of the loop or in the condition test itself. 1 extern int glob1 , glob2 ; 2 extern int f ( void ) /* @globals glob1@ */ /* @modifies > splint loop . c + infloopsuncon loop . c :7: Suspected infinite loop . No nothing@ */ ; value used in 3 extern void g ( void ) /* loop test (x , glob1 ) is modified by test or loop @modifies glob2@ */ ; body . 4 extern void h ( void ) ; loop . c :8: Suspected infinite loop . No 5 condition values modified . Modification possible 6 void upto ( int x ) { through 7 while ( x > f () ) g () ; unconstrained calls : h 8 while ( f () < 3) h () ; 9 } Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 26. Control Flow - Switches Splint detects case statements with code that may fall through to the next case. The casebreak flag controls reporting of fall through cases. The keyword fallthrough explicitly indicates that execution falls through to this case. 1 typedef enum { 2 YES , NO , DEFINITELY , 3 PROBABLY , MAYBE } ynm ; 4 5 void decide ( ynm y ) { 6 switch ( y ) { > splint switch . c 7 case PROBABLY : switch . c :9: Fall through case ( no 8 case NO : printf ( quot; No ! quot; ) ; preceding break ) switch . c :12: Missing case in switch : 9 case MAYBE : printf ( quot; DEFINITELY Maybe quot; ) ; 10 /* @fallthrough@ */ 11 case YES : printf ( quot; Yes ! quot; ); 12 } 13 } Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 27. Control Flow - Conclusion But Splint has more! Deep Breaks Complete Logic Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 28. Sum´rio a 1 Introduction 2 Unused variables 3 Types 4 Memory management 5 Control Flow 6 Buffer sizes 7 The Ultimate Test: wu-ftpd 8 Pros and Cons 9 Conclusions Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 29. Buffer sizes 1 Buffer overflow errors are a particularly dangerous type of bug in C 2 They are responsible for half of all security attacks 3 C does not perform runtime bound checking (for performance reasons) 4 Attackers can exploit program bugs to gain full access to a machine Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 30. Buffer sizes - Checking access Splint models blocks of memory using two properties: maxSet maxSet(b) denotes the highest address beyond b that can be safely used as lvalue, for instance: char buffer[MAXSIZE] we have maxSet(buffer ) = MAXSIZE − 1 maxRead maxRead(b) denotes the highest index of a buffer that can be safely used as rvalue. When a buffer is accessed as an lvalue, Splint generates a precondition constraint involving the maxSet property When a buffer is accessed as an rvalue, Splint generates a precondition constraint involving the maxRead property Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 31. Buffer sizes - Annotating Buffer Sizes 1 Function declarations may include requires and ensures clauses to specify assumptions about buffer sizes for function preconditions 2 When a function with requires clause is called, the call site must be checked to satisfy the constraints implied by requires 3 If the +checkpost is set, Splint warns if it cannot verify that a function implementation satisfies its declared postconditions Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 32. Buffer sizes - Annotating Buffer Sizes (cont.) 1 void /* @alt char * @ */ strcpy 2 ( /* @unique@ */ /* @out@ */ /* @returned@ */ char * s1 , char * s2 ) 3 /* @modifies * s1@ */ 4 /* @requires maxSet ( s1 ) >= maxRead ( s2 ) @ */ 5 /* @ensures maxRead ( s1 ) == maxRead ( s2 ) @ */ ; Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 33. Buffer sizes - Annotating Buffer Sizes (cont.) 1 void /* @alt char * @ */ strncpy 2 ( /* @unique@ */ /* @out@ */ /* @returned@ */ char * s1 , char * s2 , 3 size_t n ) 4 /* @modifies * s1@ */ 5 /* @requires maxSet ( s1 ) >= ( n - 1 ) ; @ */ 6 /* @ensures maxRead ( s2 ) >= maxRead ( s1 ) / maxRead ( s1 ) <= n ; @ */ ; Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 34. Buffer sizes - Warnings Bound checking is more complex than other checks done by Splint So, memory bound warnings contain extensive information about the unresolved constraint setChar . c :5:4: Likely out - of - bounds store : buf [10] 1 int buf [10]; Unable to resolve constraint : requires 9 2 buf [10] = 3; >= 10 needed to satisfy precondition : requires maxSet ( buf @ setChar . c :5:4) >= 10 Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 35. Buffer sizes - Warnings (cont.) > splint bounds . c + bounds + showconstraintlocation bounds . c :5: Possible out - of - bounds store : 1 void updateEnv ( char * str ) { strcpy ( str , tmp ) 2 char * tmp ; Unable to resolve constraint : requires maxSet ( str @ bounds . c :5) >= 3 tmp = getenv ( quot; MYENV quot; ) ; maxRead ( getenv (quot; MYENV quot;) @ bounds . c :3) 4 if ( tmp != NULL ) needed to satisfy precondition : 5 strcpy ( str , tmp ) ; requires maxSet ( str @ bounds . c :5) >= maxRead ( tmp @ bounds . c :5) 6 } derived from strcpy precondition : requires maxSet ( < parameter 1 >) >= maxRead ( < parameter 2 >) Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 36. Sum´rio a 1 Introduction 2 Unused variables 3 Types 4 Memory management 5 Control Flow 6 Buffer sizes 7 The Ultimate Test: wu-ftpd 8 Pros and Cons 9 Conclusions Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 37. The Ultimate Test: wu-ftpd wu-ftpd version 2.5.0 20.000 lines of code Took less than four seconds to check all of wu-ftpd on a 1.2-GHz Athlon machine Splint detected the known flaws as well as finding some previously unknown flaws (!) Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 38. The Ultimate Test: wu-ftpd (cont.) Running Splint on wu-ftpd without adding annotations produced 166 warnings for potential out-of-bounds writes After adding 66 annotations, it produced 101 warnings: 25 of these indicated real problems and 76 were false Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 39. Sum´rio a 1 Introduction 2 Unused variables 3 Types 4 Memory management 5 Control Flow 6 Buffer sizes 7 The Ultimate Test: wu-ftpd 8 Pros and Cons 9 Conclusions Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 40. Pros and Cons Pros Lightweight static analysis detects software vulnerabilities Splint definately improves code quality Suitable for real programs... Cons . . . although it produces more warning messages that lead to confusion It won’t eliminate all security risks Hasn’t been developed since 2007, they need new volunteers Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 41. Sum´rio a 1 Introduction 2 Unused variables 3 Types 4 Memory management 5 Control Flow 6 Buffer sizes 7 The Ultimate Test: wu-ftpd 8 Pros and Cons 9 Conclusions Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 42. Conclusions No tool will eliminate all security risks Lightweight static analysis tools (Splint) play an important role in identifying security vulnerabilities Pedro Pereira, Ulisses Costa Splint the C code static checker
  • 43. Questions ? Pedro Pereira, Ulisses Costa Splint the C code static checker