Changeset: 2915f1caab07 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2915f1caab07 Modified Files: monetdb5/mal/mal_profiler.c Branch: Jan2014 Log Message:
Fix "dereference after null check". diffs (35 lines): diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c --- a/monetdb5/mal/mal_profiler.c +++ b/monetdb5/mal/mal_profiler.c @@ -1342,8 +1342,7 @@ static int getCPULoad(char cpuload[BUFSI if ((n = fread(buf, 1, BUFSIZ,proc)) == 0 ) return -1; buf[n] = 0; - for ( s= buf; *s; s++) - { + for ( s= buf; *s; s++) { if ( strncmp(s,"cpu",3)== 0){ s +=3; if ( *s == ' ') { @@ -1355,7 +1354,9 @@ static int getCPULoad(char cpuload[BUFSI cpu = 255; } s= strchr(s,' '); - if ( s== 0 || cpu < 0 || cpu > 255) goto skip; + if (s == NULL) /* unexpected format of file */ + break; + if ( cpu < 0 || cpu > 255) goto skip; while( *s && isspace((int)*s)) s++; i= sscanf(s,LLFMT" "LLFMT" "LLFMT" "LLFMT" "LLFMT, &user, &nice, &system, &idle, &iowait); @@ -1370,7 +1371,9 @@ static int getCPULoad(char cpuload[BUFSI corestat[cpu].idle = idle; corestat[cpu].iowait = iowait; } - skip: if(s) while( *s && *s != '\n') s++; + skip: + while (*s && *s != '\n') + s++; } s= cpuload; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list