func
stringlengths
181
23.6k
path
stringlengths
12
123
source
stringclasses
2 values
label
int64
0
40
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; badVaSink ( data , data ); static void badVaSink(char * data, ...) va_start ( args , data ); vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
79381/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_74a.cpp
SARD
0
static void good1() if ( 5 != 5 ) char data [ 100 ] = "" ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
108914/CWE605_Multiple_Binds_Same_Port__basic_03.c
SARD
0
static void build_state(state_num s,struct dfa *d) state_num * trans ; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) setbit ( d -> tokens [ pos . index ] , matches ); static void setbit(unsigned int b,charclass c) c [ b / ( 8 * sizeof ( int ) ) ] |= 1 << b % ( 8 * sizeof ( int ) ); if ( d -> tokens [ pos . index ] >= CSET ) copyset ( d -> charclasses [ d -> tokens [ pos . index ] - CSET ] , matches ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); if ( 1 && ( d -> tokens [ pos . index ] == ANYCHAR || d -> tokens [ pos . index ] == MBCSET ) ) if ( d -> states [ s ] . mbps . nelem == 0 ) alloc_position_set ( & d -> states [ s ] . mbps , 1 ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); s -> alloc = size; s -> nelem = 0; insert ( pos , & d -> states [ s ] . mbps ); static void insert(position p,position_set *s) size_t count = s -> nelem ; size_t hi = count ; while ( lo < hi ) size_t mid = lo + hi >> 1 ; if ( s -> elems [ mid ] . index > p . index ) lo = mid + 1; hi = mid; if ( lo < count && p . index == s -> elems [ lo ] . index ) s -> elems [ lo ] . constraint |= p . constraint; if ( s -> alloc <= count + 1 ) size_t new_n_alloc = count + 1 + ( ! s -> elems ) ; s -> elems = ( x2nrealloc ( ( s -> elems ) , & new_n_alloc , sizeof ( ( * s -> elems ) ) ) ); s -> alloc = new_n_alloc; for (i = count; i > lo; i--) s -> elems [ i ] = s -> elems [ i - 1 ]; s -> elems [ lo ] = p; ++ s -> nelem; if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )) && !matches[j]; ++j) if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) copyset ( leftovers , labels [ ngrps ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); copyset ( intersect , labels [ j ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); memcpy ( grps [ ngrps ] . elems , grps [ j ] . elems , sizeof ( grps [ j ] . elems [ 0 ] ) * grps [ j ] . nelem ); grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) copyset ( matches , labels [ ngrps ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); zeroset ( matches ); static void zeroset(charclass s) memset ( s , 0 , sizeof ( charclass ) ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; alloc_position_set ( & follows , d -> nleaves ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); s -> alloc = size; s -> nelem = 0; alloc_position_set ( & tmp , d -> nleaves ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); s -> alloc = size; s -> nelem = 0; if ( d -> searchflag ) copy ( ( & d -> states [ 0 ] . elems ) , & follows ); static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; state = state_index ( d , ( & follows ) , separate_contexts ^ 7 ); static state_num state_index(struct dfa *d,const position_set *s,int context) for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) for (j = 0; j < s -> nelem; ++j) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); s -> alloc = size; s -> nelem = 0; copy ( s , & d -> states [ i ] . elems ); static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); for (j = 0; j < s -> nelem; ++j) if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; state_newline = state_index ( d , ( & follows ) , 4 ); static state_num state_index(struct dfa *d,const position_set *s,int context) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); copy ( s , & d -> states [ i ] . elems ); d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; state_newline = state; state_letter = state_index ( d , ( & follows ) , 2 ); static state_num state_index(struct dfa *d,const position_set *s,int context) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); copy ( s , & d -> states [ i ] . elems ); d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; state_letter = state; trans [ i ] = ( 1 && ( ( * __ctype_b_loc ( ) ) [ ( int ) i ] & ( ( unsigned short ) _ISalnum ) || i == '_' ) ? state_letter : state ); trans [ eolbyte ] = state_newline; trans [ i ] = ( - 1 ); for (i = 0; i < ngrps; ++i) for (j = 0; j < grps[i] . nelem; ++j) for (k = 0; k < d -> follows[grps[i] . elems[j]] . nelem; ++k) insert ( d -> follows [ grps [ i ] . elems [ j ] ] . elems [ k ] , & follows ); static void insert(position p,position_set *s) size_t count = s -> nelem ; size_t hi = count ; while ( lo < hi ) size_t mid = lo + hi >> 1 ; if ( s -> elems [ mid ] . index > p . index ) lo = mid + 1; hi = mid; if ( lo < count && p . index == s -> elems [ lo ] . index ) s -> elems [ lo ] . constraint |= p . constraint; if ( s -> alloc <= count + 1 ) size_t new_n_alloc = count + 1 + ( ! s -> elems ) ; s -> elems = ( x2nrealloc ( ( s -> elems ) , & new_n_alloc , sizeof ( ( * s -> elems ) ) ) ); s -> alloc = new_n_alloc; s -> elems [ i ] = s -> elems [ i - 1 ]; s -> elems [ lo ] = p; ++ s -> nelem; if ( d -> mb_cur_max > 1 ) for (j = 0; j < follows . nelem; ++j) if ( ! ( d -> multibyte_prop [ follows . elems [ j ] . index ] & 1 ) ) if ( d -> searchflag && ( ! 1 || ( d -> mb_cur_max == 1 || ! next_isnt_1st_byte ) ) ) for (j = 0; j < d -> states[0] . elems . nelem; ++j) insert ( d -> states [ 0 ] . elems . elems [ j ] , & follows ); static void insert(position p,position_set *s) size_t count = s -> nelem ; size_t hi = count ; while ( lo < hi ) size_t mid = lo + hi >> 1 ; if ( s -> elems [ mid ] . index > p . index ) lo = mid + 1; hi = mid; if ( lo < count && p . index == s -> elems [ lo ] . index ) s -> elems [ lo ] . constraint |= p . constraint; if ( s -> alloc <= count + 1 ) size_t new_n_alloc = count + 1 + ( ! s -> elems ) ; s -> elems = ( x2nrealloc ( ( s -> elems ) , & new_n_alloc , sizeof ( ( * s -> elems ) ) ) ); s -> alloc = new_n_alloc; s -> elems [ i ] = s -> elems [ i - 1 ]; s -> elems [ lo ] = p; ++ s -> nelem; possible_contexts = charclass_context ( labels [ i ] ); static int charclass_context(charclass c) if ( tstbit ( eolbyte , c ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; if ( c [ j ] & letters [ j ] ) if ( c [ j ] & ~ ( letters [ j ] | newline [ j ] ) ) if ( ( separate_contexts & possible_contexts ) != possible_contexts ) state = state_index ( d , ( & follows ) , separate_contexts ^ 7 ); static state_num state_index(struct dfa *d,const position_set *s,int context) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); copy ( s , & d -> states [ i ] . elems ); d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; if ( separate_contexts & possible_contexts & 4 ) state_newline = state_index ( d , ( & follows ) , 4 ); static state_num state_index(struct dfa *d,const position_set *s,int context) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); copy ( s , & d -> states [ i ] . elems ); d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; state_newline = state; if ( separate_contexts & possible_contexts & 2 ) state_letter = state_index ( d , ( & follows ) , 2 ); static state_num state_index(struct dfa *d,const position_set *s,int context) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); copy ( s , & d -> states [ i ] . elems ); d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; state_letter = state; for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) for (k = 0; k < 8 * sizeof(int ); ++k) if ( labels [ i ] [ j ] & 1 << k ) int c = ( j * ( 8 * sizeof ( int ) ) + k ) ; if ( c == eolbyte ) trans [ c ] = state_newline; if ( 1 && ( ( * __ctype_b_loc ( ) ) [ ( int ) c ] & ( ( unsigned short ) _ISalnum ) || c == '_' ) ) trans [ c ] = state_letter; if ( c < 1 << 8 ) trans [ c ] = state; for (i = 0; i < ngrps; ++i) free ( grps [ i ] . elems ); free ( grps ); if ( trans [ i ] >= d -> tralloc ) while ( trans [ i ] >= d -> tralloc ) d -> newlines [ s ] = trans [ eolbyte ]; trans [ eolbyte ] = ( - 1 ); if ( ( * d ) . states [ s ] . constraint ) d -> fails [ s ] = trans; d -> trans [ s ] = trans;
153747/dfa.c
SARD
0
void bad() wchar_t * data ; data = NULL; if ( GLOBAL_CONST_TRUE ) wchar_t * dataBuffer = new wchar_t [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
75062/CWE124_Buffer_Underwrite__new_wchar_t_memcpy_09.cpp
SARD
3
void CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_61_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] ; data = dataBuffer; data = CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_61b_badSource ( data ); wchar_t * CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_61b_badSource(wchar_t * data) wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' return data ; wchar_t dest [ 50 ] = L "" wcscat ( dest , data );
67385/CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cat_61a.c
SARD
3
void CWE369_Divide_by_Zero__int_connect_socket_modulo_32_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); * dataPtr1 = data; printIntLine ( 100 % data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
95031/CWE369_Divide_by_Zero__int_connect_socket_modulo_32.c
SARD
25
void CWE617_Reachable_Assertion__connect_socket_10_bad() if ( globalTrue ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
109437/CWE617_Reachable_Assertion__connect_socket_10.c
SARD
0
static void goodG2B1() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
73989/CWE124_Buffer_Underwrite__char_declare_loop_08.c
SARD
0
static void good1() if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; char password [ PASSWORD_INPUT_SIZE ] ; if ( fgets ( password , PASSWORD_INPUT_SIZE , stdin ) == NULL ) replace = strchr ( password , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( password , '\n' ); if ( replace ) * replace = '\0'; if ( ! CryptHashData ( hHash , ( BYTE * ) password , strlen ( password ) , 0 ) )
94558/CWE328_Reversible_One_Way_Hash__w32_SHA1_11.c
SARD
0
static void goodG2B2() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; strcat ( data , "file.txt" ); fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc );
90451/CWE23_Relative_Path_Traversal__char_file_open_08.cpp
SARD
0
CVE_2014_8643_PATCHED_XRE_InitChildProcess(int char* aArgv[]) if ( aArgc < 1 ) const int kTimeoutMs = 1000 ; MachSendMessage child_message ( 0 ) ; if ( ! child_message . AddDescriptor ( MachMsgPortDescriptor ( mach_task_self ( ) ) ) ) ReceivePort child_recv_port ; mach_port_t raw_child_recv_port = child_recv_port . GetPort ( ) ; if ( ! child_message . AddDescriptor ( MachMsgPortDescriptor ( raw_child_recv_port ) ) ) MachPortSender child_sender ( mach_port_name ) ; kern_return_t err = child_sender . SendMessage ( child_message , kTimeoutMs ) ; if ( err != KERN_SUCCESS ) MachReceiveMessage parent_message ; err = child_recv_port . WaitForMessage ( & parent_message , kTimeoutMs ); if ( err != KERN_SUCCESS ) if ( parent_message . GetTranslatedPort ( 0 ) == MACH_PORT_NULL ) err = task_set_bootstrap_port ( mach_task_self ( ) , parent_message . GetTranslatedPort ( 0 ) ); if ( err != KERN_SUCCESS ) if ( aArgc < 1 ) if ( PR_GetEnv ( "MOZ_DEBUG_CHILD_PROCESS" ) ) sleep ( 30 );
CVE-2014-8643/CVE_2014_8643_PATCHED_XRE_InitChildProcess.c
NVD
0
void CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_08_bad() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
72855/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_08.c
SARD
3
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_22_goodB2G2Sink ( data ); void CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_22_goodB2G2Sink(char * data) SNPRINTF ( dest , 100 - 1 , "%s" , data );
80365/CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_22a.c
SARD
0
void CWE194_Unexpected_Sign_Extension__connect_socket_memmove_52_bad() short data ; data = 0; WSADATA wsaData ; int recvResult ; int tempInt ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; tempInt = atoi ( inputBuffer ); if ( tempInt > SHRT_MAX || tempInt < SHRT_MIN ) data = - 1; data = tempInt; while ( 0 ) CWE194_Unexpected_Sign_Extension__connect_socket_memmove_52b_badSink ( data ); void CWE194_Unexpected_Sign_Extension__connect_socket_memmove_52b_badSink(short data) CWE194_Unexpected_Sign_Extension__connect_socket_memmove_52c_badSink ( data ); void CWE194_Unexpected_Sign_Extension__connect_socket_memmove_52c_badSink(short data) char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
86412/CWE194_Unexpected_Sign_Extension__connect_socket_memmove_52c.c
SARD
20
static void good1() if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; char data [ 100 ] = "" ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; while ( 0 ) char data [ 100 ] = "" ; size_t dataLen = strlen ( data ) ; recvResult = recv ( acceptSocket , data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
108923/CWE605_Multiple_Binds_Same_Port__basic_12.c
SARD
0
void CWE416_Use_After_Free__malloc_free_int_17_bad() int i , j ; int * data ; data = NULL; for(i = 0; i < 1; i++) data = ( int * ) malloc ( 100 * sizeof ( int ) ); size_t i ; for(i = 0; i < 100; i++) data [ i ] = 5; free ( data );
102265/CWE416_Use_After_Free__malloc_free_int_17.c
SARD
0
void bad() char * data ; data = NULL; CWE690_NULL_Deref_From_Return__char_malloc_84_bad * badObject = new CWE690_NULL_Deref_From_Return__char_malloc_84_bad ( data ) ; CWE690_NULL_Deref_From_Return__char_malloc_84_bad::CWE690_NULL_Deref_From_Return__char_malloc_84_bad(char * dataCopy) data = dataCopy; data = ( char * ) malloc ( 20 * sizeof ( char ) ); delete badObject CWE690_NULL_Deref_From_Return__char_malloc_84_bad::~CWE690_NULL_Deref_From_Return__char_malloc_84_bad() strcpy ( data , "Initialize" ); free ( data );
111073/CWE690_NULL_Deref_From_Return__char_malloc_84_bad.cpp
SARD
2
static token lex() unsigned int c ; int backslash = 0 ; charclass ccl ; int i ; for (i = 0; i < 2; ++i) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wctok = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wctok = _wc; c = ( wctob ( wctok ) ); while ( 0 ) if ( ( ( int ) c ) == - 1 ) wint_t wc ; if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wc = c = ( to_uchar ( * ( lexptr ++ ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = ( wctob ( wc ) ); while ( 0 ) while ( 0 ) switch ( c ) if ( backslash ) backslash = 1; if ( ! backslash || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return lasttok = ( CSET + charclass_index ( ccl ) ) ; static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) size_t i ; for (i = 0; i < dfa -> cindex; ++i) if ( equal ( s , dfa -> charclasses [ i ] ) ) if ( dfa -> calloc <= dfa -> cindex + 1 ) size_t new_n_alloc = dfa -> cindex + 1 + ( ! dfa -> charclasses ) ; dfa -> charclasses = ( x2nrealloc ( ( dfa -> charclasses ) , & new_n_alloc , sizeof ( ( * dfa -> charclasses ) ) ) ); dfa -> calloc = new_n_alloc; while ( 0 ) copyset ( s , dfa -> charclasses [ i ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) );
153514/dfa.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); dataArray [ 2 ] = data; badSink ( dataArray ); void badSink(char * dataArray[]) char * data = dataArray [ 2 ] ; inputFile . open ( ( char * ) data );
96584/CWE36_Absolute_Path_Traversal__char_listen_socket_ifstream_66a.cpp
SARD
0
static void goodG2B() int * data ; data = NULL; data = ( int * ) malloc ( 100 * sizeof ( int ) ); CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_loop_82_base * baseObject = new CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_loop_82_goodG2B baseObject -> action ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_loop_82_goodG2B::action(int * data) int source [ 100 ] = { 0 } ; size_t i ; for (i = 0; i < 100; i++) data [ i ] = source [ i ]; free ( data );
71693/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_loop_82_goodG2B.cpp
SARD
0
static void goodG2B() char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; if ( dataBuffer == NULL ) memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; CWE590_Free_Memory_Not_on_Heap__free_char_static_64b_goodG2BSink ( & data ); void CWE590_Free_Memory_Not_on_Heap__free_char_static_64b_goodG2BSink(void * dataVoidPtr) char * * dataPtr = ( char * * ) dataVoidPtr ; char * data = ( * dataPtr ) ; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
108206/CWE590_Free_Memory_Not_on_Heap__free_char_static_64a.c
SARD
0
static void goodB2G1() int count ; count = - 1; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; const char * filename = "output_good.txt" ; if ( count > 0 && count <= 20 ) pFile = fopen ( filename , "w+" ); for (i = 0; i < (size_t)count; i++) if ( strlen ( SENTENCE ) != fwrite ( SENTENCE , sizeof ( char ) , strlen ( SENTENCE ) , pFile ) )
98971/CWE400_Resource_Exhaustion__listen_socket_fwrite_11.c
SARD
0
static void goodB2G1() long * data ; data = NULL; data = ( long * ) realloc ( data , 1 * sizeof ( long ) ); if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; if ( data != NULL ) data [ 0 ] = 5L; free ( data );
111561/CWE690_NULL_Deref_From_Return__long_realloc_08.c
SARD
0
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket );
91972/CWE23_Relative_Path_Traversal__wchar_t_listen_socket_w32CreateFile_68a.cpp
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_64b_badSink(void * dataVoidPtr) char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
87714/CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_64b.c
SARD
20
static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; build_state ( works , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) position_set tmp ; alloc_position_set ( & tmp , d -> nleaves ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); while ( 0 ) s -> alloc = size; s -> nelem = 0;
153579/dfa.c
SARD
0
static void good1() if ( staticFalse ) if ( ! stdThreadLockCreate ( & gGoodLock ) ) int stdThreadLockCreate(stdThreadLock *lock) stdThreadLock my_lock = NULL ; my_lock = ( stdThreadLock ) malloc ( sizeof ( * my_lock ) ); if ( my_lock == NULL ) return 0 ; return 1 ; if ( ! stdThreadCreate ( helperGood , NULL , & threadB ) ) int stdThreadCreate(stdThreadRoutine start, void *args, stdThread *thread) uintptr_t handle ; stdThread my_thread ; my_thread = ( stdThread ) malloc ( sizeof ( * my_thread ) ); if ( my_thread == NULL ) my_thread -> start = start; my_thread -> args = args; handle = _beginthreadex ( NULL , 0 , internal_start , my_thread , 0 , NULL ); if ( handle == 0 ) free ( my_thread );
94606/std_thread.c
SARD
0
static void goodB2G() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL )
80933/CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_12.c
SARD
0
void CWE114_Process_Control__w32_char_connect_socket_17_bad() int i ; char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; for(i = 0; i < 1; i++) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 )
61956/CWE114_Process_Control__w32_char_connect_socket_17.c
SARD
0
static void goodB2G1() if ( globalFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) if ( count > 0 && count <= 2000 ) SLEEP ( count );
99022/CWE400_Resource_Exhaustion__listen_socket_sleep_14.c
SARD
0
void VideoSessionConduit* VideoChunk& chunk) layers :: Image * img = chunk . mFrame . GetImage ( ) ; if ( ! img ) if ( ! enabled_ || chunk . mFrame . GetForceBlack ( ) ) gfx :: IntSize size = img -> GetSize ( ) ; uint32_t yPlaneLen = YSIZE ( size . width , size . height ) ; nsAutoArrayPtr < uint8_t > pixelData ; pixelData = new ( fallible ) uint8_t [ length ] if ( pixelData ) memset ( pixelData , 0x10 , yPlaneLen ); memset ( pixelData + yPlaneLen , 0x80 , cbcrPlaneLen ); conduit -> SendVideoFrame ( pixelData , length , size . width , size . height , mozilla :: kVideoI420 , 0 );
CVE-2015-2725/Firefox_38.8.0esr_CVE_2015_2725_media_webrtc_signaling_src_mediapipeline_MediaPipeline.cpp
NVD
0
void CWE464_Addition_of_Data_Structure_Sentinel__basic_09_bad() if ( GLOBAL_CONST_TRUE ) char charArraySource [ 2 ] ; charArraySource [ 0 ] = ( char ) getc ( stdin ); charArraySource [ 1 ] = '\0'; data = ( char ) atoi ( charArraySource ); charArraySink [ 1 ] = data; charArraySink [ 2 ] = 'z'; charArraySink [ 3 ] = '\0'; printLine ( charArraySink ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
104329/CWE464_Addition_of_Data_Structure_Sentinel__basic_09.c
SARD
24
void CWE126_Buffer_Overread__malloc_char_memcpy_66_bad() char * data ; data = NULL; data = ( char * ) malloc ( 50 * sizeof ( char ) ); memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; dataArray [ 2 ] = data; CWE126_Buffer_Overread__malloc_char_memcpy_66b_badSink ( dataArray ); void CWE126_Buffer_Overread__malloc_char_memcpy_66b_badSink(char * dataArray[]) char * data = dataArray [ 2 ] ; memcpy ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
76320/CWE126_Buffer_Overread__malloc_char_memcpy_66a.c
SARD
0
static void vmsvga_update_display(void *opaque) struct vmsvga_state_s * s = opaque ; if ( ! s -> enable ) vmsvga_fifo_run ( s ); static void vmsvga_fifo_run(struct vmsvga_state_s *s) uint32_t cmd , colour ; int args , len ; int x , y , dx , dy , width , height ; struct vmsvga_cursor_definition_s cursor ; len = vmsvga_fifo_length ( s ); while ( len > 0 ) switch ( cmd = vmsvga_fifo_read ( s ) ) len -= 5; len -= 6; if ( len < 0 ) colour = vmsvga_fifo_read ( s ); x = vmsvga_fifo_read ( s ); y = vmsvga_fifo_read ( s ); width = vmsvga_fifo_read ( s ); height = vmsvga_fifo_read ( s ); if ( vmsvga_fill_rect ( s , colour , x , y , width , height ) == 0 ) args = 0; len -= 7; if ( len < 0 ) x = vmsvga_fifo_read ( s ); y = vmsvga_fifo_read ( s ); dx = vmsvga_fifo_read ( s ); dy = vmsvga_fifo_read ( s ); width = vmsvga_fifo_read ( s ); height = vmsvga_fifo_read ( s ); if ( vmsvga_copy_rect ( s , x , y , dx , dy , width , height ) == 0 ) args = 0; len -= 8; if ( len < 0 ) cursor . id = vmsvga_fifo_read ( s ); cursor . hot_x = vmsvga_fifo_read ( s ); cursor . hot_y = vmsvga_fifo_read ( s ); cursor . width = x = vmsvga_fifo_read ( s ); cursor . height = y = vmsvga_fifo_read ( s ); cursor . bpp = vmsvga_fifo_read ( s ); args = SVGA_BITMAP_SIZE ( x , y ) + SVGA_PIXMAP_SIZE ( x , y , cursor . bpp ); if ( SVGA_BITMAP_SIZE ( x , y ) > sizeof cursor . mask || SVGA_PIXMAP_SIZE ( x , y , cursor . bpp ) > sizeof cursor . image ) len -= args; if ( len < 0 ) for (args = 0; args < SVGA_BITMAP_SIZE(x, y); args++) cursor . mask [ args ] = vmsvga_fifo_read_raw ( s ); for (args = 0; args < SVGA_PIXMAP_SIZE(x, y, cursor.bpp); args++) cursor . image [ args ] = vmsvga_fifo_read_raw ( s ); len -= 6; if ( len < 0 ) x = vmsvga_fifo_read ( s ); y = vmsvga_fifo_read ( s ); args = x * y; args = 6; args = 7; len -= 4; if ( len < 0 ) args = 7 + ( vmsvga_fifo_read ( s ) >> 2 ); args = 12; args = 0; len -= args; if ( len < 0 ) while ( args -- ) static inline int vmsvga_copy_rect(struct vmsvga_state_s int x0, int y0, int x1, int y1, int w, int h) DisplaySurface * surface = qemu_console_surface ( s -> vga . con ) ; if ( ! vmsvga_verify_rect ( surface , "vmsvga_copy_rect/src" , x0 , y0 , w , h ) ) if ( ! vmsvga_verify_rect ( surface , "vmsvga_copy_rect/dst" , x1 , y1 , w , h ) ) static inline bool vmsvga_verify_rect(DisplaySurface const char int x, int y, int w, int h) if ( x < 0 ) if ( x > SVGA_MAX_WIDTH ) if ( w < 0 ) if ( w > SVGA_MAX_WIDTH ) if ( x + w > surface_width ( surface ) ) if ( y < 0 ) if ( y > SVGA_MAX_HEIGHT ) fprintf ( stderr , "%s: y was > %d (%d)\n" , name , SVGA_MAX_HEIGHT , y );
CVE-2016-4454/qemu_2.3.0_CVE-2016-4454_vmware_vga.c
NVD
0
static void goodG2B() list < int > dataList ; goodG2BSink ( dataList ); void goodG2BSink(list<int> dataList) int data = dataList . back ( ) ; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
88152/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memmove_73b.cpp
SARD
0
void svn_config_get(svn_config_t *cfg,const char **valuep,const char *section,const char *option,const char *default_value) * valuep = default_value; if ( cfg ) cfg_section_t * sec ; cfg_option_t * opt = find_option ( cfg , section , option , & sec ) ; if ( opt != ( ( void * ) 0 ) ) make_string_from_option ( valuep , cfg , sec , opt , ( ( void * ) 0 ) ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) ) apr_pool_t * tmp_pool = x_pool ? x_pool : svn_pool_create_ex ( cfg -> x_pool , ( ( void * ) 0 ) ) ; expand_option_value ( cfg , section , opt -> value , & opt -> x_value , tmp_pool ); static void expand_option_value(svn_config_t *cfg,cfg_section_t *section,const char *opt_value,const char **opt_x_valuep,apr_pool_t *x_pool) const char * parse_from = opt_value ; const char * name_start ; const char * name_end ; while ( parse_from != ( ( void * ) 0 ) && ( * parse_from ) != '\0' && ( name_start = ( strstr ( parse_from , "%(" ) ) ) != ( ( void * ) 0 ) ) name_start += sizeof ( "%(" ) - 1; if ( ( * name_start ) == '\0' ) name_end = ( strstr ( name_start , ")s" ) ); if ( name_end != ( ( void * ) 0 ) ) cfg_option_t * x_opt ; apr_size_t len = ( name_end - name_start ) ; char * name = apr_pstrmemdup ( x_pool , name_start , len ) ; x_opt = find_option ( cfg , section -> name , name , ( ( void * ) 0 ) ); static cfg_option_t *find_option(svn_config_t *cfg,const char *section,const char *option,cfg_section_t **sectionp) svn_stringbuf_set ( cfg -> tmp_key , section ); if ( ! cfg -> section_names_case_sensitive ) make_hash_key ( cfg -> tmp_key -> data ); inline static char *make_hash_key(char *key) for (p = key; ( *p) != 0; ++p) * p = ( ( char ) ( tolower ( ( ( unsigned char ) ( * p ) ) ) ) ); return key ; sec_ptr = apr_hash_get ( cfg -> sections , ( cfg -> tmp_key -> data ) , ( cfg -> tmp_key -> len ) ); if ( sectionp != ( ( void * ) 0 ) ) * sectionp = sec_ptr; if ( sec_ptr != ( ( void * ) 0 ) && option != ( ( void * ) 0 ) ) cfg_section_t * sec = sec_ptr ; svn_stringbuf_set ( cfg -> tmp_key , option ); if ( ! cfg -> option_names_case_sensitive ) make_hash_key ( cfg -> tmp_key -> data ); inline static char *make_hash_key(char *key) * p = ( ( char ) ( tolower ( ( ( unsigned char ) ( * p ) ) ) ) ); return key ; opt = ( apr_hash_get ( sec -> options , ( cfg -> tmp_key -> data ) , ( cfg -> tmp_key -> len ) ) ); if ( opt == ( ( void * ) 0 ) && apr_strnatcasecmp ( section , "DEFAULT" ) != 0 ) opt = find_option ( cfg , "DEFAULT" , option , & sec ); return opt ; if ( x_opt != ( ( void * ) 0 ) ) const char * cstring ; make_string_from_option ( & cstring , cfg , section , x_opt , x_pool ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = ( ( void * ) 0 ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) )
150890/config.c
SARD
0
void CWE114_Process_Control__w32_wchar_t_connect_socket_05_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticTrue ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket );
62232/CWE114_Process_Control__w32_wchar_t_connect_socket_05.c
SARD
0
void CWE400_Resource_Exhaustion__fscanf_fwrite_08_bad() if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; const char * filename = "output_bad.txt" ; pFile = fopen ( filename , "w+" ); if ( pFile == NULL ) if ( strlen ( SENTENCE ) != fwrite ( SENTENCE , sizeof ( char ) , strlen ( SENTENCE ) , pFile ) ) if ( pFile ) fclose ( pFile );
98824/CWE400_Resource_Exhaustion__fscanf_fwrite_08.c
SARD
0
static void goodG2B2() short data ; data = 0; if ( GLOBAL_CONST_TRUE ) data = 100 - 1; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; printLine ( dataBuffer ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dataBuffer );
86678/CWE194_Unexpected_Sign_Extension__fscanf_malloc_09.c
SARD
0
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; free ( stonesoup_tainted_buff );
149794/utils.c
SARD
0
void CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_ncpy_66_bad() char * data ; char * dataArray [ 5 ] ; char * dataBadBuffer = ( char * ) ALLOCA ( ( 10 ) * sizeof ( char ) ) ; data = dataBadBuffer; data [ 0 ] = '\0'; dataArray [ 2 ] = data; CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_ncpy_66b_badSink ( dataArray ); void CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_ncpy_66b_badSink(char * dataArray[]) char * data = dataArray [ 2 ] ; char source [ 10 + 1 ] = SRC_STRING ; strncpy ( data , source , strlen ( source ) + 1 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
63224/CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_ncpy_66b.c
SARD
3
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_51_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_51b_badSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_51b_badSink(char * data) strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
65685/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_51a.c
SARD
0
CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_printf_83_goodB2G::CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_printf_83_goodB2G(wchar_t * dataCopy) data = dataCopy; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket );
81784/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_printf_83_goodB2G.cpp
SARD
0
int file_read(void *buf,unsigned int len,FILE_T file) unsigned int n ; if ( len == 0 ) if ( file -> seek ) file -> seek = 0; if ( gz_skip ( file , file -> skip ) == - 1 ) static int gz_skip(FILE_T state,gint64 len) unsigned int n ; while ( len ) if ( state -> have ) n = ( ( ( gint64 ) ( state -> have ) ) > len ? ( ( unsigned int ) len ) : state -> have ); state -> have -= n; state -> next += n; state -> pos += n; len -= n; if ( state -> err ) return - 1 ; if ( state -> eof && state -> avail_in == 0 ) if ( fill_out_buffer ( state ) == - 1 ) return - 1 ; return 0 ; if ( file -> have ) n = ( file -> have > len ? len : file -> have ); file -> next += n; file -> have -= n; if ( file -> err ) if ( file -> eof && file -> avail_in == 0 ) if ( fill_out_buffer ( file ) == - 1 ) len -= n; file -> pos += n; while ( len ) static int fill_out_buffer(FILE_T state) if ( state -> compression == 0 ) if ( gz_head ( state ) == - 1 ) if ( state -> have ) if ( state -> compression == 1 ) if ( state -> compression == 2 ) zlib_read ( state , state -> out , state -> size << 1 ); static void zlib_read(FILE_T state,unsigned char *buf,unsigned int count) z_streamp strm = & state -> strm ; unsigned char * buf2 = buf ; unsigned int count2 = count ; strm -> avail_out = count; strm -> next_out = buf; if ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ) if ( state -> avail_in == 0 ) strm -> avail_in = state -> avail_in; strm -> next_in = state -> next_in; ret = inflate ( strm , 5 ); state -> avail_in = strm -> avail_in; state -> next_in = strm -> next_in; if ( ret == - 2 ) if ( ret == 2 ) if ( ret == - 4 ) if ( ret == - 3 ) strm -> adler = crc32 ( strm -> adler , buf2 , count2 - strm -> avail_out ); if ( state -> fast_seek_cur ) struct zlib_cur_seek_point * cur = ( struct zlib_cur_seek_point * ) ( state -> fast_seek_cur ) ; unsigned int ready = count2 - strm -> avail_out ; if ( ready < 32768 ) unsigned int left = 32768 - cur -> pos ; if ( ready >= left ) memcpy ( ( cur -> window + cur -> pos ) , buf2 , left ); if ( ready != left ) memcpy ( ( cur -> window ) , ( buf2 + left ) , ( ready - left ) ); cur -> pos = ready - left; cur -> have += ready; memcpy ( ( cur -> window + cur -> pos ) , buf2 , ready ); cur -> pos += ready; cur -> have += ready; if ( cur -> have >= 32768 ) cur -> have = 32768; memcpy ( ( cur -> window ) , ( buf2 + ( ready - 32768 ) ) , 32768 ); cur -> pos = 0; cur -> have = 32768; if ( cur -> have >= 32768 && ret != 1 && strm -> data_type & 128 && ! ( strm -> data_type & 64 ) ) zlib_fast_seek_add ( state , cur , strm -> data_type & 7 , state -> raw_pos - ( strm -> avail_in ) , state -> pos + ( count - strm -> avail_out ) ); buf2 = buf2 + count2 - strm -> avail_out; count2 = strm -> avail_out; while ( strm -> avail_out && ret != 1 ) static void zlib_fast_seek_add(FILE_T file,struct zlib_cur_seek_point *point,int bits,gint64 in_pos,gint64 out_pos) struct fast_seek_point * item = ( struct fast_seek_point * ) file -> fast_seek -> pdata [ file -> fast_seek -> len - 1 ] ; if ( item -> out + 1048576L < out_pos ) struct fast_seek_point * val = ( struct fast_seek_point * ) ( g_malloc_n ( 1 , sizeof ( struct fast_seek_point ) ) ) ; val -> in = in_pos; val -> out = out_pos; val -> compression = 2; val -> data . zlib . bits = bits; if ( point -> pos != 0 ) unsigned int left = 32768 - point -> pos ; memcpy ( val -> data . zlib . window , ( point -> window + point -> pos ) , left ); memcpy ( ( val -> data . zlib . window + left ) , ( point -> window ) , ( point -> pos ) );
150145/file_wrappers.c
SARD
0
void bad() char * data ; map < int , char * > dataMap ; data = new char [ 100 ]; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; char dest [ 50 ] = "" ; strcat ( dest , data );
70203/CWE122_Heap_Based_Buffer_Overflow__cpp_src_char_cat_74b.cpp
SARD
3
void CWE400_Resource_Exhaustion__listen_socket_sleep_41_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); badSink ( count ); static void badSink(int count) SLEEP ( count );
99033/CWE400_Resource_Exhaustion__listen_socket_sleep_41.c
SARD
12
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_environment_66_bad() wchar_t * data ; wchar_t * dataArray [ 5 ] ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' size_t dataLen = wcslen ( data ) ; wchar_t * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); dataArray [ 2 ] = data; CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_environment_66b_badSink ( dataArray ); void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_environment_66b_badSink(wchar_t * dataArray[]) wchar_t * data = dataArray [ 2 ] ; free ( data );
112941/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_environment_66b.c
SARD
1
svn_error_t *svn_uri_condense_targets(const char **pcommon,apr_array_header_t **pcondensed_targets,const apr_array_header_t *targets,svn_boolean_t remove_redundancies,apr_pool_t *result_pool,apr_pool_t *scratch_pool) int i ; if ( targets -> nelts <= 0 ) * pcommon = svn_uri_canonicalize ( ( ( const char * * ) ( targets -> elts ) ) [ 0 ] , scratch_pool ); const char *svn_uri_canonicalize(const char *uri,apr_pool_t *pool) return canonicalize ( type_uri , uri , pool ) ; static const char *canonicalize(path_type_t type,const char *path,apr_pool_t *pool) char * canon ; char * dst ; const char * src ; apr_size_t seglen ; apr_size_t schemelen = 0 ; apr_size_t canon_segments = 0 ; svn_boolean_t url = 0 ; char * schema_data = ( ( void * ) 0 ) ; if ( path [ 0 ] == '\0' ) return "" ; dst = canon = ( memset ( apr_palloc ( pool , strlen ( path ) + 1 ) , 0 , strlen ( path ) + 1 ) ); src = path; if ( type == type_uri ) while ( * src && ( * src ) != 47 && ( * src ) != ':' ) src ++; if ( ( * src ) == ':' && ( * ( src + 1 ) ) == 47 && ( * ( src + 2 ) ) == 47 ) const char * seg ; url = ! 0; src = path; while ( ( * src ) != ':' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; schemelen ++; * ( dst ++ ) = ':'; * ( dst ++ ) = 47; * ( dst ++ ) = 47; src += 3; schemelen += 3; seg = src; while ( * src && ( * src ) != 47 && ( * src ) != 64 ) src ++; if ( ( * src ) == 64 ) seglen = ( src - seg + 1 ); memcpy ( dst , seg , seglen ); dst += seglen; src ++; src = seg; if ( ( * src ) == '[' ) * ( dst ++ ) = * ( src ++ ); while ( ( * src ) == ':' || ( * src ) >= 48 && ( * src ) <= '9' || ( * src ) >= 'a' && ( * src ) <= 'f' || ( * src ) >= 65 && ( * src ) <= 'F' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; if ( ( * src ) == ']' ) * ( dst ++ ) = * ( src ++ ); while ( * src && ( * src ) != 47 && ( * src ) != ':' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; if ( ( * src ) == ':' ) if ( src [ 1 ] == 56 && src [ 2 ] == 48 && ( src [ 3 ] == 47 || ! src [ 3 ] ) && ! strncmp ( canon , "http:" , 5 ) ) src += 3; if ( src [ 1 ] == 52 && src [ 2 ] == 52 && src [ 3 ] == 51 && ( src [ 4 ] == 47 || ! src [ 4 ] ) && ! strncmp ( canon , "https:" , 6 ) ) src += 4; if ( src [ 1 ] == 51 && src [ 2 ] == '6' && src [ 3 ] == '9' && src [ 4 ] == 48 && ( src [ 5 ] == 47 || ! src [ 5 ] ) && ! strncmp ( canon , "svn:" , 4 ) ) src += 5; if ( src [ 1 ] == 47 || ! src [ 1 ] ) src += 1; while ( * src && ( * src ) != 47 ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; * dst = * src; if ( * src ) src ++; dst ++; schema_data = dst; canon_segments = 1; if ( ! url && type != type_relpath ) src = path; if ( ( * src ) == 47 ) * ( dst ++ ) = * ( src ++ ); while ( * src ) const char * next = src ; apr_size_t slash_len = 0 ; if ( next [ 0 ] == 47 ) slash_len = 1; if ( type == type_uri && next [ 0 ] == 37 ) slash_len = 3; seglen = ( next - src ); if ( seglen == 0 || seglen == 1 && src [ 0 ] == 46 || type == type_uri && seglen == 3 && src [ 0 ] == 37 && src [ 1 ] == 50 && ( canonicalize_to_upper ( src [ 2 ] ) ) == 'E' ) static char canonicalize_to_upper(char c) if ( c < 'a' || c > 'z' ) return c ; return ( char ) ( c - 'a' + 65 ) ; memcpy ( dst , src , seglen ); dst += seglen; if ( slash_len ) * ( dst ++ ) = 47; canon_segments ++; src = next + slash_len; if ( canon_segments > 0 && ( * ( dst - 1 ) ) == 47 && ! ( url && path [ schemelen ] == '\0' ) ) dst --; * dst = '\0'; if ( schema_data ) int need_extra = 0 ; src = schema_data; while ( * src ) switch ( * src ) if ( ! ( 0 != ( svn_ctype_table [ ( unsigned char ) ( * ( src + 1 ) ) ] & ( 0x0004 | 0x0040 ) ) ) || ! ( 0 != ( svn_ctype_table [ ( unsigned char ) ( * ( src + 2 ) ) ] & ( 0x0004 | 0x0040 ) ) ) ) need_extra += 2; src += 2; if ( ! svn_uri__char_validity [ ( unsigned char ) ( * src ) ] ) need_extra += 2; src ++; if ( need_extra > 0 ) apr_size_t pre_schema_size = ( apr_size_t ) ( schema_data - canon ) ; dst = ( apr_palloc ( pool , ( ( apr_size_t ) ( src - canon ) ) + need_extra + 1 ) ); memcpy ( dst , canon , pre_schema_size ); canon = dst; return canon ; if ( targets -> nelts == 1 ) for (i = 1; i < targets -> nelts; ++i) const char * uri = svn_uri_canonicalize ( ( ( const char * * ) ( targets -> elts ) ) [ i ] , scratch_pool ) ; const char *svn_uri_canonicalize(const char *uri,apr_pool_t *pool) return canonicalize ( type_uri , uri , pool ) ; if ( ( * ( * pcommon ) ) != '\0' ) * pcommon = ( svn_uri_get_longest_ancestor ( * pcommon , uri , scratch_pool ) ); char *svn_uri_get_longest_ancestor(const char *uri1,const char *uri2,apr_pool_t *pool) apr_size_t uri_ancestor_len ; apr_size_t i = 0 ; while ( 1 ) if ( uri1 [ i ] != uri2 [ i ] ) return ( apr_pmemdup ( pool , "" , sizeof ( "" ) ) ) ; if ( uri1 [ i ] == ':' ) i ++; i += 3; uri_ancestor_len = get_longest_ancestor_length ( type_uri , uri1 + i , uri2 + i , pool ); static apr_size_t get_longest_ancestor_length(path_type_t types,const char *path1,const char *path2,apr_pool_t *pool) apr_size_t path1_len ; apr_size_t path2_len ; apr_size_t i = 0 ; apr_size_t last_dirsep = 0 ; path1_len = strlen ( path1 ); path2_len = strlen ( path2 ); if ( path1 [ 0 ] == '\0' || path2 [ 0 ] == '\0' ) return 0 ; while ( path1 [ i ] == path2 [ i ] ) if ( path1 [ i ] == 47 ) last_dirsep = i; i ++; if ( i == path1_len || i == path2_len ) if ( i == 1 && path1 [ 0 ] == 47 && path2 [ 0 ] == 47 ) return 1 ; if ( types == type_dirent && i == 0 ) return 0 ; if ( i == path1_len && path2 [ i ] == 47 || i == path2_len && path1 [ i ] == 47 || i == path1_len && i == path2_len ) return i ; if ( last_dirsep == 0 && path1 [ 0 ] == 47 && path2 [ 0 ] == 47 ) return 1 ; return last_dirsep ; if ( uri_ancestor_len == 0 || uri_ancestor_len == 1 && ( uri1 + i ) [ 0 ] == 47 ) return ( apr_pmemdup ( pool , "" , sizeof ( "" ) ) ) ; return apr_pstrndup ( pool , uri1 , uri_ancestor_len + i ) ; * pcommon = ( apr_pstrdup ( result_pool , * pcommon ) ); if ( pcondensed_targets != ( ( void * ) 0 ) ) size_t basedir_len ; basedir_len = strlen ( * pcommon ); if ( basedir_len > 0 ) rel_item += basedir_len; if ( rel_item [ 0 ] == 47 || rel_item [ 0 ] && ! svn_uri_is_root ( * pcommon , basedir_len ) ) svn_boolean_t svn_uri_is_root(const char *uri,apr_size_t len) svn_uri_is_canonical ( uri , ( ( void * ) 0 ) ) ? ( ( void ) 0 ) : __assert_fail ( "svn_uri_is_canonical(uri, ((void *)0))" , "dirent_uri.c" , 958 , __PRETTY_FUNCTION__ ); svn_boolean_t svn_uri_is_canonical(const char *uri,apr_pool_t *scratch_pool) const char * ptr = uri ; const char * seg = uri ; if ( ( * uri ) == '\0' ) if ( ! svn_path_is_url ( uri ) ) while ( * ptr && ( * ptr ) != 47 && ( * ptr ) != ':' ) ptr ++; if ( ! ( ( * ptr ) == ':' && ( * ( ptr + 1 ) ) == 47 && ( * ( ptr + 2 ) ) == 47 ) ) ptr = uri; while ( ( * ptr ) != ':' ) if ( ( * ptr ) >= 65 && ( * ptr ) <= 'Z' ) ptr ++; ptr += 3; if ( ! ( * ptr ) ) seg = ptr; while ( * ptr && ( * ptr ) != 47 && ( * ptr ) != 64 ) ptr ++; if ( ( * ptr ) == 64 ) seg = ptr + 1; ptr = seg; if ( ( * ptr ) == '[' ) ptr ++; while ( ( * ptr ) == ':' || ( * ptr ) >= 48 && ( * ptr ) <= '9' || ( * ptr ) >= 'a' && ( * ptr ) <= 'f' ) ptr ++; if ( ( * ptr ) != ']' ) ptr ++; while ( * ptr && ( * ptr ) != 47 && ( * ptr ) != ':' ) if ( ( * ptr ) >= 65 && ( * ptr ) <= 'Z' ) ptr ++; if ( ( * ptr ) == ':' ) ptr ++; schema_data = ptr; while ( ( * ptr ) >= 48 && ( * ptr ) <= '9' ) port = 10 * port + ( ( * ptr ) - 48 ); ptr ++; if ( ptr == schema_data ) if ( * ptr && ( * ptr ) != 47 ) if ( port == 80 && strncmp ( uri , "http:" , 5 ) == 0 ) if ( port == 443 && strncmp ( uri , "https:" , 6 ) == 0 ) if ( port == 3690 && strncmp ( uri , "svn:" , 4 ) == 0 ) schema_data = ptr; apr_size_t seglen = ( ptr - seg ) ; if ( seglen == 1 && ( * seg ) == 46 ) if ( ( * ptr ) == 47 && ( * ( ptr + 1 ) ) == 47 ) if ( ! ( * ptr ) && ( * ( ptr - 1 ) ) == 47 && ptr - 1 != uri ) if ( ! ( * ptr ) ) if ( ( * ptr ) == 47 ) ptr ++; seg = ptr; while ( * ptr && ( * ptr ) != 47 ) ptr ++; ptr = schema_data; while ( * ptr ) if ( ( * ptr ) == 37 ) if ( ( ( * ( ptr + 1 ) ) < 48 || ( * ( ptr + 1 ) ) > '9' ) && ( ( * ( ptr + 1 ) ) < 65 || ( * ( ptr + 1 ) ) > 'F' ) ) if ( ( ( * ( ptr + 2 ) ) < 48 || ( * ( ptr + 2 ) ) > '9' ) && ( ( * ( ptr + 2 ) ) < 65 || ( * ( ptr + 2 ) ) > 'F' ) ) digitz [ 0 ] = * ( ++ ptr ); digitz [ 1 ] = * ( ++ ptr ); digitz [ 2 ] = '\0'; val = ( ( int ) ( strtol ( digitz , ( ( void * ) 0 ) , 16 ) ) ); if ( svn_uri__char_validity [ val ] ) if ( ( * ptr ) != 47 && ! svn_uri__char_validity [ ( unsigned char ) ( * ptr ) ] ) ptr ++; return len == uri_schema_root_length ( uri , len ) ; static apr_size_t uri_schema_root_length(const char *uri,apr_size_t len) for (i = 0; i < len; i++) if ( uri [ i ] == 47 ) if ( i > 0 && uri [ i - 1 ] == ':' && i < len - 1 && uri [ i + 1 ] == 47 ) if ( i == 5 && strncmp ( "file" , uri , 4 ) == 0 ) for (i += 2; i < len; i++) if ( uri [ i ] == 47 ) return len ; rel_item ++; * ( ( const char * * ) ( apr_array_push ( * pcondensed_targets ) ) ) = svn_path_uri_decode ( rel_item , result_pool );
153755/dirent_uri.c
SARD
0
void CWE194_Unexpected_Sign_Extension__listen_socket_malloc_45_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; tempInt = atoi ( inputBuffer ); if ( tempInt > SHRT_MAX || tempInt < SHRT_MIN ) data = tempInt; while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); CWE194_Unexpected_Sign_Extension__listen_socket_malloc_45_badData = data;
86890/CWE194_Unexpected_Sign_Extension__listen_socket_malloc_45.c
SARD
0
static int xc2028_set_analog_freq(struct dvb_frontend struct analog_parameters *p) struct xc2028_data * priv = fe -> tuner_priv ; unsigned int type = 0 ; if ( p -> mode == V4L2_TUNER_RADIO ) type |= FM; if ( priv -> ctrl . input1 ) type |= INPUT1; return generic_set_freq ( fe , ( 625l * p -> frequency ) / 10 , V4L2_TUNER_RADIO , type , 0 , 0 ) ; static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ enum v4l2_tuner_type unsigned int v4l2_std_id u16 int_freq) if ( check_firmware ( fe , type , std , int_freq ) < 0 ) static int check_firmware(struct dvb_frontend *fe, unsigned int v4l2_std_id std, __u16 int_freq) struct xc2028_data * priv = fe -> tuner_priv ; struct firmware_properties new_fw ; int rc , retry_count = 0 ; u16 version , hwmodel ; v4l2_std_id std0 ; rc = check_device_status ( priv ); if ( rc < 0 ) if ( priv -> ctrl . mts && ! ( type & FM ) ) type |= MTS; new_fw . type = type; new_fw . id = std; new_fw . std_req = std; new_fw . scode_table = SCODE | priv -> ctrl . scode_table; new_fw . scode_nr = 0; new_fw . int_freq = int_freq; dump_firm_type ( new_fw . type ); printk ( "(%x), id %016llx, " , new_fw . type , ( unsigned long long ) new_fw . std_req ); dump_firm_type ( priv -> ctrl . scode_table ); printk ( "(%x), " , priv -> ctrl . scode_table ); printk ( "int_freq %d, " , new_fw . int_freq ); printk ( "scode_nr %d\n" , new_fw . scode_nr ); if ( ( priv -> state == XC2028_ACTIVE ) && ( ( ( BASE | new_fw . type ) & BASE_TYPES ) == ( priv -> cur_fw . type & BASE_TYPES ) ) ) memset ( & priv -> cur_fw , 0 , sizeof ( priv -> cur_fw ) ); rc = do_tuner_callback ( fe , XC2028_TUNER_RESET , 0 ); if ( rc < 0 ) std0 = 0; rc = load_firmware ( fe , BASE | new_fw . type , & std0 ); if ( rc < 0 ) tuner_err ( "Error %d while loading base firmware\n" , rc ); rc = load_firmware ( fe , BASE | INIT1 | new_fw . type , & std0 ); if ( rc == - ENOENT ) rc = load_firmware ( fe , ( BASE | INIT1 | new_fw . type ) & ~F8MHZ , & std0 ); if ( rc < 0 && rc != - ENOENT ) tuner_err ( "Error %d while loading init1 firmware\n" , rc ); if ( priv -> cur_fw . type == ( BASE | new_fw . type ) && priv -> cur_fw . std_req == std ) priv -> cur_fw . scode_table = 0; rc = load_firmware ( fe , new_fw . type , & new_fw . id ); if ( rc == - ENOENT ) rc = load_firmware ( fe , new_fw . type & ~F8MHZ , & new_fw . id ); if ( rc < 0 ) if ( priv -> cur_fw . scode_table == new_fw . scode_table && priv -> cur_fw . scode_nr == new_fw . scode_nr ) if ( new_fw . type & FM ) tuner_dbg ( "Trying to load scode %d\n" , new_fw . scode_nr ); rc = load_scode ( fe , new_fw . type | new_fw . scode_table , & new_fw . id , new_fw . int_freq , new_fw . scode_nr ); if ( xc2028_get_reg ( priv , 0x0004 , & version ) < 0 || xc2028_get_reg ( priv , 0x0008 , & hwmodel ) < 0 ) if ( priv -> ctrl . read_not_reliable ) if ( priv -> firm_version != ( ( version & 0xf0 ) << 4 | ( version & 0x0f ) ) ) if ( ! priv -> ctrl . read_not_reliable ) hwmodel = 3028; if ( priv -> hwmodel == 0 && ( hwmodel == 2028 || hwmodel == 3028 ) ) priv -> hwmodel = hwmodel; priv -> hwvers = version & 0xff00; if ( priv -> hwmodel == 0 || priv -> hwmodel != hwmodel || priv -> hwvers != ( version & 0xff00 ) ) priv -> cur_fw = new_fw; priv -> cur_fw . type |= BASE; priv -> state = XC2028_ACTIVE; priv -> state = XC2028_NO_FIRMWARE; memset ( & priv -> cur_fw , 0 , sizeof ( priv -> cur_fw ) ); if ( retry_count < 8 ) retry_count ++; if ( rc == - ENOENT ) return rc ;
CVE-2016-7913/linux_kernel_4.2.5_CVE_2016_7913_drivers_media_tuners_tuner-xc2028.c
NVD
0
static void goodG2B1() int count ; count = - 1; if ( STATIC_CONST_FALSE ) count = 20; if ( STATIC_CONST_TRUE ) const char * filename = "output_bad.txt" ; pFile = fopen ( filename , "w+" ); for (i = 0; i < (size_t)count; i++) if ( strlen ( SENTENCE ) != fwrite ( SENTENCE , sizeof ( char ) , strlen ( SENTENCE ) , pFile ) )
98532/CWE400_Resource_Exhaustion__connect_socket_fwrite_04.c
SARD
0
static void goodG2B2() wchar_t * data ; data = NULL; if ( GLOBAL_CONST_FIVE == 5 ) data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncpy ( data , source , 100 - 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
72140/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_13.c
SARD
0
void bad() vector < wchar_t * > dataVector ; badSink ( dataVector ); void badSink(vector<wchar_t *> dataVector) wchar_t * data = dataVector [ 2 ] ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); data [ 100 - 1 ] = L '\0' free ( data );
72025/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_memcpy_72b.cpp
SARD
3
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) inputFile . open ( ( char * ) data );
96558/CWE36_Absolute_Path_Traversal__char_listen_socket_ifstream_13.cpp
SARD
4
static void eepro100_write4(EEPRO100State * s, uint32_t addr, uint32_t val) switch ( addr ) eepro100_write_port ( s ); static void eepro100_write_port(EEPRO100State *s) uint32_t val = e100_read_reg4 ( s , SCBPort ) ; static uint32_t e100_read_reg4(EEPRO100State *s, E100RegisterOffset addr) return le32_to_cpup ( ( uint32_t * ) & s -> mem [ addr ] ) ; uint8_t selection = ( val & PORT_SELECTION_MASK ) ; switch ( selection ) nic_reset ( s ); static void nic_reset(void *opaque) EEPRO100State * s = opaque ; memset ( & s -> mult [ 0 ] , 0 , sizeof ( s -> mult ) ); nic_selective_reset ( s ); static void nic_selective_reset(EEPRO100State * s) uint16_t * eeprom_contents = eeprom93xx_data ( s -> eeprom ) ; memcpy ( eeprom_contents , s -> conf . macaddr . a , 6 ); eeprom_contents [ EEPROM_ID ] = EEPROM_ID_VALID; eeprom_contents [ 5 ] = 0x0100; eeprom_contents [ EEPROM_PHY_ID ] = 1; sum += eeprom_contents [ i ]; eeprom_contents [ EEPROM_SIZE - 1 ] = 0xbaba - sum; TRACE ( EEPROM , logout ( "checksum=0x%04x\n" , eeprom_contents [ EEPROM_SIZE - 1 ] ) );
CVE-2016-9101/qemu_2.3.0_CVE-2016-9101_eepro100.c
NVD
0
static void goodG2B2() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); if ( staticFive == 5 ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; strcat ( dest , data ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
72998/CWE122_Heap_Based_Buffer_Overflow__c_src_char_cat_07.c
SARD
0
static void goodB2G() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; size_t passwordLen = strlen ( password ) ; recvResult = recv ( connectSocket , ( char * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( password , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( password , '\n' ); if ( replace ) * replace = '\0'; passwordMap [ 0 ] = password; passwordMap [ 1 ] = password; passwordMap [ 2 ] = password; goodB2GSink ( passwordMap ); void goodB2GSink(map<int, char *> passwordMap) char * password = passwordMap [ 2 ] ; payloadBytes = decodeHexChars ( payload , sizeof ( payload ) , password ); size_t decodeHexChars(unsigned char * bytes, size_t numBytes, const char * hex) while ( numWritten < numBytes && isxdigit ( hex [ 2 * numWritten ] ) && isxdigit ( hex [ 2 * numWritten + 1 ] ) ) sscanf ( & hex [ 2 * numWritten ] , "%02x" , & byte ); bytes [ numWritten ] = ( unsigned char ) byte; return numWritten ; SecureZeroMemory ( password , 100 * sizeof ( char ) ); memcpy ( password , payload , payloadBytes ); password [ payloadBytes / sizeof ( char ) ] = '\0'; if ( LogonUserA ( username , domain , password , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & pHandle ) != 0 )
94141/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_74a.cpp
SARD
0
void CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__accept_listen_bind_01_bad() char data [ 100 ] = "" ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 )
109963/CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__accept_listen_bind_01.c
SARD
36
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *morazan_acedias) int muchfold_cardiocirrhosis ; struct picolin_reminted enforcer_gothicizing [ 10 ] = { 0 } ; struct picolin_reminted misprision_lungflower ; if ( morazan_acedias != 0 ) misprision_lungflower . kingsman_rostroantennary = ( ( char * ) morazan_acedias ); muchfold_cardiocirrhosis = 5; dynamotor_mastigure = & muchfold_cardiocirrhosis; bettongia_nonaspirating = & dynamotor_mastigure; goajiro_nattier = & bettongia_nonaspirating; voidableness_anend = & goajiro_nattier; meatometer_tonal = & voidableness_anend; inbreath_unburied = & meatometer_tonal; raasch_sharlene = & inbreath_unburied; indescribably_urbias = & raasch_sharlene; coiffing_biometry = & indescribably_urbias; dampy_polygamian = & coiffing_biometry; enforcer_gothicizing [ * ( * ( * ( * ( * ( * ( * ( * ( * ( * dampy_polygamian ) ) ) ) ) ) ) ) ) ] = misprision_lungflower; sheartail_janene = enforcer_gothicizing [ * ( * ( * ( * ( * ( * ( * ( * ( * ( * dampy_polygamian ) ) ) ) ) ) ) ) ) ]; moiling_frgs = ( ( char * ) sheartail_janene . kingsman_rostroantennary ); stonesoup_str = malloc ( sizeof ( char ) * ( strlen ( moiling_frgs ) + 1 ) ); stonesoup_sleep_file = malloc ( sizeof ( char ) * ( strlen ( moiling_frgs ) + 1 ) ); if ( stonesoup_str != NULL && stonesoup_sleep_file != NULL && ( sscanf ( moiling_frgs , "%s %s" , stonesoup_sleep_file , stonesoup_str ) == 2 ) && ( strlen ( stonesoup_str ) != 0 ) && ( strlen ( stonesoup_sleep_file ) != 0 ) ) if ( stonesoup_path_is_relative ( stonesoup_str ) ) int stonesoup_path_is_relative(char *path) chr = strchr ( path , '/' ); if ( chr == 0 ) return 1 ; return 0 ; stonesoup_abs_path = stonesoup_get_absolute_path ( stonesoup_str ); char * stonesoup_get_absolute_path(char * path) char * abs_path = malloc ( sizeof ( char ) * ( strlen ( "/opt/stonesoup/workspace/testData/" ) * strlen ( path ) + 1 ) ) ; if ( abs_path == NULL ) strcpy ( abs_path , "/opt/stonesoup/workspace/testData/" ); tracepoint ( stonesoup_trace , variable_buffer , "abs_path" , abs_path , "Generated absolute path" ); strcat ( abs_path , path ); return abs_path ;
149982/pmsignal.c
SARD
0
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_03_bad() char * data ; data = NULL; if ( 5 == 5 ) data = ( char * ) malloc ( 50 * sizeof ( char ) ); data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncat ( data , source , 100 ); free ( data );
71362/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_03.c
SARD
3
static void good2() if ( STATIC_CONST_FIVE == 5 ) BYTE payload [ 100 ] ; DWORD payloadLen = strlen ( PAYLOAD ) ; HCRYPTPROV hCryptProv = ( HCRYPTPROV ) NULL ; HCRYPTHASH hHash = ( HCRYPTHASH ) NULL ; HCRYPTKEY hKey = ( HCRYPTKEY ) NULL ; char hashData [ 100 ] = HASH_INPUT ; memcpy ( payload , PAYLOAD , payloadLen ); if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptEncrypt ( hKey , 0 , 1 , 0 , payload , & payloadLen , sizeof ( payload ) ) ) while ( 0 )
94409/CWE325_Missing_Required_Cryptographic_Step__w32_CryptDeriveKey_06.c
SARD
0
static int skinny_hangup(struct ast_channel *ast) struct skinny_subchannel * sub = ast -> tech_pvt ; if ( ! sub ) dumpsub ( sub , 1 ); static void dumpsub(struct skinny_subchannel *sub, int forcehangup) struct skinny_line * l = sub -> line ; if ( ! forcehangup && sub -> substate == SUBSTATE_HOLD ) if ( sub == l -> activesub ) if ( sub -> related ) setsubstate ( sub , SUBSTATE_ONHOOK ); static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) sub -> substate = SUBSTATE_HOLD; if ( actualstate == sub -> substate ) switch ( actualstate ) l -> activesub = sub; sub -> substate = SUBSTATE_OFFHOOK; if ( sub -> related ) sub -> related -> related = NULL; if ( sub == l -> activesub ) l -> activesub = NULL; sub -> cxmode = SKINNY_CX_RECVONLY; sub -> substate = SUBSTATE_ONHOOK; if ( sub -> rtp ) sub -> rtp = NULL; if ( ast_strlen_zero ( sub -> exten ) || ! ast_exists_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) sub -> substate = SUBSTATE_DIALING; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS ) ) sub -> substate = SUBSTATE_RINGOUT; sub -> substate = SUBSTATE_RINGIN; sub -> substate = SUBSTATE_CALLWAIT; sub -> substate = SUBSTATE_CONNECTED; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS || sub -> substate == SUBSTATE_RINGOUT ) ) sub -> substate = SUBSTATE_BUSY; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS || sub -> substate == SUBSTATE_RINGOUT ) ) sub -> substate = SUBSTATE_CONGESTION; if ( sub -> substate != SUBSTATE_DIALING ) ast_log ( LOG_WARNING , "Cannot set substate to SUBSTATE_PROGRESS from %s (on call-%d)\n" , substate2str ( sub -> substate ) , sub -> callid ); static char *substate2str(int ind) char * tmp ; switch ( ind ) if ( ! ( tmp = ast_threadstorage_get ( & substate2str_threadbuf , SUBSTATE2STR_BUFSIZE ) ) ) snprintf ( tmp , SUBSTATE2STR_BUFSIZE , "UNKNOWN-%d" , ind ); return tmp ;
148809/chan_skinny.c
SARD
0
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_10_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); size_t dataLen = wcslen ( data ) ; recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) replace = wcschr ( data , L '\r' ) if ( replace ) replace = wcschr ( data , L '\n' ) if ( replace ) for ( * data != L '\0' data ++ ) if ( * data == SEARCH_CHAR ) free ( data );
112816/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_10.c
SARD
1
static void goodG2B() int data ; CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_34_unionType myUnion ; data = - 1; data = 100 - 1; myUnion . unionFirst = data; int data = myUnion . unionSecond ; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
87701/CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_34.c
SARD
0
void CWE78_OS_Command_Injection__char_listen_socket_system_03_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; if ( 5 == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 )
120009/CWE78_OS_Command_Injection__char_listen_socket_system_03.c
SARD
0
static int goodB2GSource(int data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) return data ;
67545/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE129_connect_socket_42.cpp
SARD
0
static void goodG2B() short data ; data = 0; data = 100 - 1; CWE194_Unexpected_Sign_Extension__fscanf_memmove_41_goodG2BSink ( data ); void CWE194_Unexpected_Sign_Extension__fscanf_memmove_41_goodG2BSink(short data) char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
86790/CWE194_Unexpected_Sign_Extension__fscanf_memmove_41.c
SARD
0
void CWE134_Uncontrolled_Format_String__char_connect_socket_vfprintf_05_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticTrue ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 )
79246/CWE134_Uncontrolled_Format_String__char_connect_socket_vfprintf_05.c
SARD
0
static void PgstatCollectorMain(int argc,char *argv[]) pgstat_write_statsfile ( ( ( bool ) 1 ) ); static void pgstat_write_statsfile(bool permanent) FILE * fpout ; const char * tmpfile = ( permanent ? "global/pgstat.tmp" : pgstat_stat_tmpname ) ; fpout = AllocateFile ( tmpfile , "w" ); if ( fpout == ( ( void * ) 0 ) ) if ( ferror ( fpout ) ) if ( FreeFile ( fpout ) < 0 ) unlink ( tmpfile );
153393/pgstat.c
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_08_bad() int data ; data = - 1; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
87733/CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_08.c
SARD
20
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
79302/CWE134_Uncontrolled_Format_String__char_connect_socket_vprintf_13.c
SARD
0
void CWE134_Uncontrolled_Format_String__char_environment_vfprintf_31_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 100 - dataLen - 1 ); char * dataCopy = data ; char * data = dataCopy ; badVaSink ( data , data ); static void badVaSink(char * data, ...) va_start ( args , data ); vfprintf ( stdout , data , args );
79838/CWE134_Uncontrolled_Format_String__char_environment_vfprintf_31.c
SARD
15
static void goodG2B() char * data ; data = NULL; while ( 1 ) char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
74733/CWE124_Buffer_Underwrite__new_char_cpy_16.cpp
SARD
0
static void goodB2G2() size_t data ; data = 0; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = rand ( ); if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; if ( data > wcslen ( HELLO_STRING ) && data < 100 )
117425/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_11.c
SARD
0
void CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_68b_badSink() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
72888/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_68b.c
SARD
3
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_32_bad() char * data ; char * * dataPtr1 = & data ; char * * dataPtr2 = & data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); char * data = * dataPtr1 ; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; char * data = * dataPtr2 ; char dest [ 50 ] = "" ; SNPRINTF ( dest , strlen ( data ) , "%s" , data );
72485/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_32.c
SARD
3
void CWE126_Buffer_Overread__malloc_wchar_t_memcpy_02_bad() wchar_t * data ; data = NULL; if ( 1 ) data = ( wchar_t * ) malloc ( 50 * sizeof ( wchar_t ) ); wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memcpy ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
76427/CWE126_Buffer_Overread__malloc_wchar_t_memcpy_02.c
SARD
3
void CWE124_Buffer_Underwrite__wchar_t_declare_memmove_17_bad() int i ; wchar_t * data ; wchar_t dataBuffer [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' for(i = 0; i < 1; i++) data = dataBuffer - 8; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memmove ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
75534/CWE124_Buffer_Underwrite__wchar_t_declare_memmove_17.c
SARD
3
tvbuff_t CVE_2011_2174_PATCHED_tvb_uncompress(tvbuff_t *tvb, const int offset, int comprlen) guint bytes_out = 0 ; guint8 * uncompr = NULL ; gint wbits = MAX_WBITS ; if ( tvb == NULL ) compr = tvb_memdup ( tvb , offset , comprlen ); if ( ! compr ) bufsiz = tvb_length_remaining ( tvb , offset ) * 2; bufsiz = CLAMP ( bufsiz , TVB_Z_MIN_BUFSIZ , TVB_Z_MAX_BUFSIZ ); next = compr; strm = g_new0 ( z_stream , 1 ); strm -> next_in = next; strm -> avail_in = comprlen; strmbuf = g_malloc0 ( bufsiz ); strm -> next_out = strmbuf; strm -> avail_out = bufsiz; err = inflateInit2 ( strm , wbits ); inits_done = 1; if ( err != Z_OK ) while ( 1 ) memset ( strmbuf , '\0' , bufsiz ); strm -> next_out = strmbuf; strm -> avail_out = bufsiz; err = inflate ( strm , Z_SYNC_FLUSH ); if ( err == Z_OK || err == Z_STREAM_END ) guint bytes_pass = bufsiz - strm -> avail_out ; if ( uncompr == NULL ) uncompr = g_memdup ( strmbuf , bytes_pass ); guint8 * new_data = g_malloc0 ( bytes_out + bytes_pass ) ; uncompr = new_data; bytes_out += bytes_pass; if ( err == Z_STREAM_END ) if ( err == Z_BUF_ERROR ) if ( err == Z_DATA_ERROR && inits_done == 1 && uncompr == NULL && ( * compr == 0x1f ) && ( * ( compr + 1 ) == 0x8b ) ) Bytef * c = compr + 2 ; if ( * c == Z_DEFLATED ) c ++; flags = * c; c += 7; if ( flags & ( 1 << 2 ) ) gint xsize = ( gint ) ( * c | ( * ( c + 1 ) << 8 ) ) ; c += xsize; if ( flags & ( 1 << 3 ) ) while ( ( c - compr ) < comprlen && * c != '\0' ) c ++; c ++; if ( flags & ( 1 << 4 ) ) while ( ( c - compr ) < comprlen && * c != '\0' ) c ++; c ++; next = c; if ( c - compr > comprlen ) comprlen -= ( int ) ( c - compr ); inits_done ++; if ( err == Z_DATA_ERROR && uncompr == NULL && inits_done <= 3 ) wbits = - MAX_WBITS; strm -> next_in = next; strm -> avail_in = comprlen; memset ( strmbuf , '\0' , bufsiz ); strm -> next_out = strmbuf; strm -> avail_out = bufsiz; err = inflateInit2 ( strm , wbits ); inits_done ++; if ( err != Z_OK ) g_free ( strm ); g_free ( strmbuf );
CVE-2011-2174/CVE_2011_2174_PATCHED_tvb_uncompress.c
NVD
0
static void goodG2B() wchar_t * data ; data = NULL; wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; CWE590_Free_Memory_Not_on_Heap__free_wchar_t_declare_51b_goodG2BSink ( data ); void CWE590_Free_Memory_Not_on_Heap__free_wchar_t_declare_51b_goodG2BSink(wchar_t * data) free ( data );
108761/CWE590_Free_Memory_Not_on_Heap__free_wchar_t_declare_51b.c
SARD
0
void pgstat_report_activity(BackendState state,const char *cmd_str) volatile PgBackendStatus * beentry = MyBEEntry ; if ( ! beentry ) if ( ! pgstat_track_activities && ( beentry -> st_state ) != STATE_DISABLED ) if ( cmd_str != ( ( void * ) 0 ) ) len = pg_mbcliplen ( cmd_str , ( strlen ( cmd_str ) ) , pgstat_track_activity_query_size - 1 ); memcpy ( ( ( char * ) ( beentry -> st_activity ) ) , cmd_str , len ); beentry -> st_activity [ len ] = '\0'; beentry -> st_activity_start_timestamp = start_timestamp; beentry -> st_changecount ++;
153810/pgstat.c
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__rand_memcpy_09_bad() int data ; data = - 1; if ( GLOBAL_CONST_TRUE ) data = RAND32 ( ); char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
88454/CWE195_Signed_to_Unsigned_Conversion_Error__rand_memcpy_09.c
SARD
20
void CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_53_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_53b_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_53b_badSink(char * data) CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_53c_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_53c_badSink(char * data) CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_53d_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_53d_badSink(char * data) badVaSink ( data , data ); static void badVaSink(char * data, ...) va_start ( args , data ); vprintf ( data , args );
80473/CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_53a.c
SARD
0
static void expand_option_value(svn_config_t *cfg,cfg_section_t *section,const char *opt_value,const char **opt_x_valuep,apr_pool_t *x_pool) const char * parse_from = opt_value ; const char * name_start ; const char * name_end ; while ( parse_from != ( ( void * ) 0 ) && ( * parse_from ) != '\0' && ( name_start = ( strstr ( parse_from , "%(" ) ) ) != ( ( void * ) 0 ) ) name_start += sizeof ( "%(" ) - 1; if ( ( * name_start ) == '\0' ) name_end = ( strstr ( name_start , ")s" ) ); if ( name_end != ( ( void * ) 0 ) ) cfg_option_t * x_opt ; apr_size_t len = ( name_end - name_start ) ; char * name = apr_pstrmemdup ( x_pool , name_start , len ) ; x_opt = find_option ( cfg , section -> name , name , ( ( void * ) 0 ) ); if ( x_opt != ( ( void * ) 0 ) ) const char * cstring ; make_string_from_option ( & cstring , cfg , section , x_opt , x_pool ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = ( ( void * ) 0 ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) ) apr_pool_t * tmp_pool = x_pool ? x_pool : svn_pool_create_ex ( cfg -> x_pool , ( ( void * ) 0 ) ) ; expand_option_value ( cfg , section , opt -> value , & opt -> x_value , tmp_pool ); static void expand_option_value(svn_config_t *cfg,cfg_section_t *section,const char *opt_value,const char **opt_x_valuep,apr_pool_t *x_pool) const char * parse_from = opt_value ; const char * name_start ; const char * name_end ; while ( parse_from != ( ( void * ) 0 ) && ( * parse_from ) != '\0' && ( name_start = ( strstr ( parse_from , "%(" ) ) ) != ( ( void * ) 0 ) ) name_start += sizeof ( "%(" ) - 1; if ( ( * name_start ) == '\0' ) name_end = ( strstr ( name_start , ")s" ) ); if ( name_end != ( ( void * ) 0 ) ) cfg_option_t * x_opt ; apr_size_t len = ( name_end - name_start ) ; char * name = apr_pstrmemdup ( x_pool , name_start , len ) ; x_opt = find_option ( cfg , section -> name , name , ( ( void * ) 0 ) ); if ( x_opt != ( ( void * ) 0 ) ) const char * cstring ; make_string_from_option ( & cstring , cfg , section , x_opt , x_pool ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = ( ( void * ) 0 ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) ) opt -> expanded = ! 0; if ( ! x_pool ) if ( opt -> x_value ) opt -> x_value = ( apr_pstrmemdup ( cfg -> x_pool , opt -> x_value , strlen ( opt -> x_value ) ) ); if ( opt -> x_value ) * valuep = opt -> x_value; * valuep = opt -> value;
149303/config.c
SARD
0
void pgstat_reset_single_counter(Oid objoid,PgStat_Single_Reset_Type type) PgStat_MsgResetsinglecounter msg ; if ( pgStatSock == - 1 ) msg . m_databaseid = MyDatabaseId; msg . m_resettype = type; msg . m_objectid = objoid; pgstat_send ( ( & msg ) , ( sizeof ( msg ) ) ); static void pgstat_send(void *msg,int len) int rc ; if ( pgStatSock == - 1 ) ( ( PgStat_MsgHdr * ) msg ) -> m_size = len; rc = ( send ( pgStatSock , msg , len , 0 ) ); while ( rc < 0 && * __errno_location ( ) == 4 )
153393/pgstat.c
SARD
0
static void goodB2G() twoIntsStruct * data ; data = NULL; data = ( twoIntsStruct * ) malloc ( 1 * sizeof ( twoIntsStruct ) ); CWE690_NULL_Deref_From_Return__struct_malloc_53b_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__struct_malloc_53b_goodB2GSink(twoIntsStruct * data) CWE690_NULL_Deref_From_Return__struct_malloc_53c_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__struct_malloc_53c_goodB2GSink(twoIntsStruct * data) CWE690_NULL_Deref_From_Return__struct_malloc_53d_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__struct_malloc_53d_goodB2GSink(twoIntsStruct * data) if ( data != NULL ) data [ 0 ] . intOne = 1; data [ 0 ] . intTwo = 1; free ( data );
111681/CWE690_NULL_Deref_From_Return__struct_malloc_53d.c
SARD
0
static void goodG2B() int h ; for(h = 0; h < 1; h++) wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; data = dataBuffer; wcsncpy ( data , source , 100 - 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
74686/CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_17.c
SARD
0
static enum doContent(XML_Parser int const ENCODING const char const char const char XML_Bool haveMore) DTD * const dtd = _dtd const char * * eventPP ; if ( enc == encoding ) eventPP = & eventPtr; eventPP = & ( openInternalEntities -> internalEventPtr ); const char * next = s ; int tok = XmlContentTok ( enc , s , end , & next ) ; switch ( tok ) const XML_Char * name ; ENTITY * entity ; XML_Char ch = ( XML_Char ) XmlPredefinedEntityName ( enc , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar ) ; if ( ch ) name = poolStoreString ( & dtd -> pool , enc , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar ); if ( ! name ) entity = ( ENTITY * ) lookup ( & dtd -> generalEntities , name , 0 ); if ( ! dtd -> hasParamEntityRefs || dtd -> standalone ) if ( ! entity ) if ( ! entity -> is_internal ) if ( ! entity ) if ( entity -> open ) if ( entity -> notation ) if ( entity -> textPtr ) enum XML_Error result ; if ( ! defaultExpandInternalEntities ) result = processInternalEntity ( parser , entity , XML_FALSE ); if ( result != XML_ERROR_NONE ) if ( externalEntityRefHandler ) const XML_Char * context ; entity -> open = XML_TRUE; context = getContext ( parser ); entity -> open = XML_FALSE; if ( ! context ) if ( ! externalEntityRefHandler ( externalEntityRefHandlerArg , context , entity -> base , entity -> systemId , entity -> publicId ) ) TAG * tag ; enum XML_Error result ; XML_Char * toPtr ; if ( freeTagList ) tag = freeTagList; freeTagList = freeTagList -> parent; tag = ( TAG * ) MALLOC ( sizeof ( TAG ) ); if ( ! tag ) tag -> buf = ( char * ) MALLOC ( INIT_TAG_BUF_SIZE ); if ( ! tag -> buf ) tag -> bufEnd = tag -> buf + INIT_TAG_BUF_SIZE; tag -> bindings = NULL; tag -> parent = tagStack; tagStack = tag; tag -> name . localPart = NULL; tag -> name . prefix = NULL; tag -> rawName = s + enc -> minBytesPerChar; tag -> rawNameLength = XmlNameLength ( enc , tag -> rawName ); const char * rawNameEnd = tag -> rawName + tag -> rawNameLength ; const char * fromPtr = tag -> rawName ; toPtr = ( XML_Char * ) tag -> buf; int bufSize ; int convLen ; convLen = ( int ) ( toPtr - ( XML_Char * ) tag -> buf ); if ( fromPtr == rawNameEnd ) tag -> name . strLen = convLen; bufSize = ( int ) ( tag -> bufEnd - tag -> buf ) << 1; char * temp = ( char * ) REALLOC ( tag -> buf , bufSize ) ; if ( temp == NULL ) tag -> buf = temp; tag -> bufEnd = temp + bufSize; toPtr = ( XML_Char * ) temp + convLen; tag -> name . str = ( XML_Char * ) tag -> buf; result = storeAtts ( parser , enc , s , & ( tag -> name ) , & ( tag -> bindings ) ); if ( result ) const char * rawName = s + enc -> minBytesPerChar ; enum XML_Error result ; TAG_NAME name ; name . str = poolStoreString ( & tempPool , enc , rawName , rawName + XmlNameLength ( enc , rawName ) ); if ( ! name . str ) result = storeAtts ( parser , enc , s , & name , & bindings ); if ( result ) if ( tagLevel == 0 ) if ( tagLevel == startTagLevel ) int len ; const char * rawName ; TAG * tag = tagStack ; tagStack = tag -> parent; tag -> parent = freeTagList; freeTagList = tag; rawName = s + enc -> minBytesPerChar * 2; len = XmlNameLength ( enc , rawName ); if ( len != tag -> rawNameLength || memcmp ( tag -> rawName , rawName , len ) != 0 ) while ( tag -> bindings ) tag -> bindings = tag -> bindings -> nextTagBinding; if ( tagLevel == 0 ) int n = XmlCharRefNumber ( enc , s ) ; if ( n < 0 ) enum XML_Error result ; result = doCdataSection ( parser , enc , & next , end , nextPtr , haveMore ); if ( result != XML_ERROR_NONE ) if ( ! next ) if ( characterDataHandler ) if ( MUST_CONVERT ( enc , s ) ) if ( s == next ) * eventPP = s; if ( ! reportProcessingInstruction ( parser , enc , s , next ) ) if ( ! reportComment ( parser , enc , s , next ) ) * eventPP = s = next; switch ( ps_parsing ) static XML_Char poolStoreString(STRING_POOL *pool, const ENCODING const char *ptr, const char *end) if ( ! poolAppend ( pool , enc , ptr , end ) ) static XML_Char poolAppend(STRING_POOL *pool, const ENCODING const char *ptr, const char *end) if ( ! pool -> ptr && ! poolGrow ( pool ) ) if ( ptr == end ) if ( ! poolGrow ( pool ) ) static XML_Bool poolGrow(STRING_POOL *pool) if ( pool -> freeBlocks ) if ( pool -> start == 0 ) if ( pool -> end - pool -> start < pool -> freeBlocks -> size ) if ( pool -> blocks && pool -> start == pool -> blocks -> s ) BLOCK * tem ; int blockSize = ( int ) ( pool -> end - pool -> start ) ; if ( blockSize < INIT_BLOCK_SIZE ) blockSize = INIT_BLOCK_SIZE; blockSize *= 2; tem = ( BLOCK * ) pool -> mem -> malloc_fcn ( offsetof ( BLOCK , s ) + blockSize * sizeof ( XML_Char ) ); if ( ! tem ) tem -> size = blockSize; tem -> next = pool -> blocks; pool -> blocks = tem; if ( pool -> ptr != pool -> start ) memcpy ( tem -> s , pool -> start , ( pool -> ptr - pool -> start ) * sizeof ( XML_Char ) ); pool -> ptr = tem -> s + ( pool -> ptr - pool -> start ); pool -> start = tem -> s; pool -> end = tem -> s + blockSize;
CVE-2015-2716/Firefox_37.0b7_CVE_2015_2716_parser_expat_lib_xmlparse.c
NVD
0
static void goodG2B() wchar_t * data ; wchar_t * dataGoodBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBadBuffer , L 'A' , 50 - 1 dataBadBuffer [ 50 - 1 ] = L wmemset ( dataGoodBuffer , L 'A' , 100 - 1 dataGoodBuffer [ 100 - 1 ] = L '\0' while ( 1 ) data = dataGoodBuffer; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memcpy ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
76865/CWE126_Buffer_Overread__wchar_t_alloca_memcpy_16.c
SARD
0
static void goodG2B2() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; if ( staticTrue ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
65948/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncat_05.c
SARD
0
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; unsigned char saved_end ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; saved_end = * ( ( unsigned char * ) end ); * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) * end = saved_end; s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) int mbclen ; int maxlen = 0 ; size_t i ; int * match_lens = ( ( void * ) 0 ) ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) transit_state_consume_1char ( d , s , pp , match_lens , & mbclen , & follows ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) state_num s1 ; s1 = s; copy ( ( & d -> states [ s1 ] . elems ) , pps );
149947/dfa.c
SARD
0
CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_83_bad::CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_83_bad(char * dataCopy) data = dataCopy; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 )
80296/CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_83_bad.cpp
SARD
0
gboolean try_conversation_dissector(const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,tvbuff_t *tvb,packet_info *pinfo,proto_tree *tree) conversation_t * conversation ; conversation = find_conversation ( pinfo -> fd -> num , addr_a , addr_b , ptype , port_a , port_b , 0 ); conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( conversation -> options & 0x01 ) && ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_b , 0 ); if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , 0 , port_a ); conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2_or_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_b , port_b ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , addr2 , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr2 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation -> key_ptr = new_key; conversation_insert_into_hashtable ( hashtable , conversation ); return conversation ;
149441/conversation.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( globalFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
95743/CWE36_Absolute_Path_Traversal__char_connect_socket_w32CreateFile_14.cpp
SARD
0
static proto_item _proto_tree_add_bits_ret_val(proto_tree *tree, const int hfindex, tvbuff_t const guint bit_offset, const gint guint64 *return_value, const guint encoding) gint offset ; guint length ; guint8 tot_no_bits ; char lbl_str [ ITEM_LABEL_LENGTH ] ; proto_item * pi ; header_field_info * hf_field ; offset = bit_offset >> 3; tot_no_bits = ( ( bit_offset & 0x7 ) + no_of_bits ); length = ( tot_no_bits + 7 ) >> 3; if ( no_of_bits < 65 ) value = tvb_get_bits64 ( tvb , bit_offset , no_of_bits , encoding ); switch ( hf_field -> type ) value = ws_sign_ext64 ( value , no_of_bits ); switch ( hf_field -> type ) pi = proto_tree_add_uint ( tree , hfindex , tvb , offset , length , ( guint32 ) value ); fill_label_number ( PITEM_FINFO ( pi ) , lbl_str , FALSE ); static fill_label_number(field_info *fi, gchar *label_str, gboolean is_signed) header_field_info * hfinfo = fi -> hfinfo ; if ( hfinfo -> display == BASE_CUSTOM ) gchar tmp [ ITEM_LABEL_LENGTH ] ; if ( hfinfo -> strings && hfinfo -> type != FT_FRAMENUM ) if ( IS_BASE_PORT ( hfinfo -> display ) ) gchar tmp [ ITEM_LABEL_LENGTH ] ; label_fill ( label_str , 0 , hfinfo , tmp ); static label_fill(char *label_str, gsize pos, const header_field_info *hfinfo, const char *text) gsize name_pos ; name_pos = pos = label_concat ( label_str , pos , hfinfo -> name ); pos = label_concat ( label_str , pos , ": " ); pos = label_concat ( label_str , pos , text ? text : "(null)" ); if ( pos >= ITEM_LABEL_LENGTH ) label_mark_truncated ( label_str , name_pos ); static label_mark_truncated(char *label_str, gsize name_pos) const size_t trunc_len = sizeof ( trunc_str ) - 1 ; if ( name_pos < ITEM_LABEL_LENGTH - trunc_len ) memmove ( label_str + name_pos + trunc_len , label_str + name_pos , ITEM_LABEL_LENGTH - name_pos - trunc_len ); memcpy ( label_str + name_pos , trunc_str , trunc_len ); last_char = g_utf8_prev_char ( & label_str [ ITEM_LABEL_LENGTH ] ); * last_char = '\0'; g_strlcpy ( label_str + name_pos , trunc_str , ITEM_LABEL_LENGTH - name_pos );
CVE-2016-4006/Wireshark_2.0.2_CVE_2016_4006_epan_proto.c
NVD
0
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_03_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) fclose ( pFile );
112953/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_03.c
SARD
0
static void goodB2G() wchar_t * data ; CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_listen_socket_34_unionType myUnion ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( wchar_t ) ] = L '\0' while ( 0 ) myUnion . unionFirst = data; wchar_t * data = myUnion . unionSecond ; free ( data );
113070/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_listen_socket_34.c
SARD
0
void svn_stream_set_close(svn_stream_t *stream,svn_close_fn_t close_fn) char * supplier_unconstrainedly ; if ( __sync_bool_compare_and_swap ( & novelet_underbury , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) supplier_unconstrainedly = getenv ( "JEDDA_COPERIODIC" ); if ( supplier_unconstrainedly != 0 ) trauchled_catchflies = ( ( void * ) supplier_unconstrainedly ); malloy_anagallis = swartzite_dryopians ( trauchled_catchflies ); void *swartzite_dryopians(void *nonorganic_nondevious) return nonorganic_nondevious ; demobilisation_cowskins = ( ( char * ) ( ( char * ) malloy_anagallis ) ); stonesoup_csv = fopen ( demobilisation_cowskins , "r" ); if ( stonesoup_csv != 0 ) stonesoup_temp = fopen ( "/opt/stonesoup/workspace/testData/myfile.txt" , "w+" ); if ( stonesoup_temp != 0 ) fclose ( stonesoup_temp );
149894/stream.c
SARD
0
void CWE194_Unexpected_Sign_Extension__rand_strncpy_67b_goodG2BSink(CWE194_Unexpected_Sign_Extension__rand_strncpy_67_structType myStruct) char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
87429/CWE194_Unexpected_Sign_Extension__rand_strncpy_67b.c
SARD
0
void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_listen_socket_03_bad() size_t data ; data = 0; if ( 5 == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( 5 == 5 ) wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); free ( myString );
117369/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_listen_socket_03.c
SARD
10