Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Integer Overflow of Allocation Size  at cmds.c:2327

Categories: ALLOC.IOAS BSI:MALLOC-OVERFLOW CWE:680
Warning ID: 525.29316
Procedure: spawn_cmd
Trace: view
Modified: Thu Nov 26 11:37:05 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
ProblemLineSource
   /kat0/fletcher/SATE/2010/pvm3/console/cmds.c
   Enter spawn_cmd
 2187 spawn_cmd(ac, av) 
 2188         int ac;
 2189         char **av;
 2190 {
 2191         int *tids = 0;
 2192         char *where = 0;
 2193         int flags = PvmNoSpawnParent;
 2194         int count = 1;
 2195         int i;
 2196         int oflg = 0;
 2197         int tflg = 0;
 2198         int app;
 2199         char *ofn = 0;
 2200         char *tfn = 0;
 2201         struct job *jp, *jp2;
 2202         void status_msg();
 2203         void event_dump_hdr();
 2204         void output_dump_hdr();
 2205         int fd;
 2206  
 2207         while (av[1][0] == '-') {
 2208                 if (ac < 3) {
 2209                         fputs("incorrect arg count\n", stdout);
 2210                         return 1;
 2211                 }
 2212                 if (av[1][1] == '~') {
 2213                         flags |= PvmHostCompl;
 2214                         av[1]++;
 2215                 }
 2216                 if (av[1][1] == '.' || islower(av[1][1])) {   /* Negative Character Value (ID: 17.28599) */
 2217                         where = av[1] + 1;
 2218                         flags |= PvmTaskHost;
 2219                 }
 2220                 if (av[1][1] == ':')
 2221                         where = av[1] + 1;
 2222                 if (isupper(av[1][1])) {   /* Negative Character Value (ID: 18.28600) */
 2223                         where = av[1] + 1;
 2224                         flags |= PvmTaskArch;
 2225                 }
 2226                 if (av[1][1] == '?')
 2227                         flags |= PvmTaskDebug;
 2228                 if (isdigit(av[1][1]))   /* Negative Character Value (ID: 19.28601) */
 2229                         count = atoi(av[1] + 1);
 2230                 if (av[1][1] == '>') {
 2231                         oflg = 1;
 2232                         app = 0;
 2233                         ofn = av[1] + 2;
 2234                         if (av[1][2] == '>') {
 2235                                 app = 1;
 2236                                 ofn++;
 2237                         }
 2238                         if (!*ofn)
 2239                                 ofn = 0;
 2240 /*
 2241                         printf("%s to %s\n", (app ? "Append" : "Write"),
 2242                                         (ofn ? ofn : "(console)"));
 2243 */ 
 2244                 }
 2245                 if (av[1][1] == '@') {
 2246                         tflg = 1;
 2247                         tfn = av[1] + 2;
 2248                         if (!*tfn)
 2249                                 tfn = "";
 2250                 }
 2251                 /* gnu-like host (where) arg, allows IP's to be used... */ 
 2252                 if (av[1][1] == '-') {
 2253                         if ( !strncmp( &(av[1][2]), "host=", 5 ) ) {
 2254                                 where = av[1] + 7;
 2255                                 flags |= PvmTaskHost;
 2256                         }
 2257                 }
 2258                 av++;
 2259                 ac--;
 2260         }
 2261         if (tflg) {
 2262                 jp2 = job_new(nextjob);
 2263                 jp2->j_flag |= JOB_TRACE;
 2264                 jp2->j_trcid = trc_get_tracer_id();
 2265                 jp2->j_trcid->status_msg = status_msg;
 2266                 if (tfn && !strcmp(tfn,""))
 2267                         jp2->j_trcid->event_dump_hdr = event_dump_hdr;
 2268                 if (oflg && !ofn) ofn = "";
 2269                 if (ofn)
 2270                         jp2->j_trcid->output_dump_hdr = output_dump_hdr;
 2271                 jp2->j_trcid->event_ctx = pvm_getcontext();
   ...
 2283                 trc_save_host_status_events( jp2->j_trcid );
 2284                 if (ofn) {
 2285                         trc_set_output_file( jp2->j_trcid, ofn );
 2286                         if (!trc_open_output_file( jp2->j_trcid )) {
 2287                                 job_free(jp2);
 2288                                 return 1;
 2289                         }
 2290                 }
 2291                 oflg = 0;
 2292         }
 2293         else {
 2294                 pvm_setopt(PvmTraceTid, 0);
 2295  
 2296                 if (oflg) {
 2297                         pvm_setopt(PvmOutputTid, mytid);
 2298                         pvm_setopt(PvmOutputContext, pvm_getcontext());
 2299                         pvm_setopt(PvmOutputCode, nextjob);
 2300                         jp = job_new(nextjob);
 2301                         printf("[%d]\n", nextjob - joboffset);
 2302                         nextjob++;
 2303                         if (ofn) {
 2304                                 if ( app ) {
 2305                                         fd = open( ofn,
 2306                                                 O_RDWR|O_APPEND|O_CREAT|O_EXCL|O_TRUNC, 0600 );
 2307                                 }
 2308                                 else {
 2309                                         fd = open( ofn, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600 );
 2310                                 }
 2311                                 if (fd < 0) {
 2312                                         perror(ofn);
 2313                                         job_free(jp);
 2314                                         return 1;
 2315                                 }
 2316                                 jp->j_ff = fdopen( fd, (app ? "a" : "w") );
 2317                                 if (!jp->j_ff) {
 2318                                         perror(ofn);
 2319                                         job_free(jp);
 2320                                         return 1;
 2321                                 }
 2322                         }
 2323                 } else 
 2324                         pvm_setopt(PvmOutputTid, 0);
 2325         }
 2326  
true2327         tids = TALLOC(count > 1 ? count : 1, int, "int");     /* Integer Overflow of Allocation Size */
Preconditions
ac >= 3
&$unknown_12303612 != 0
&$unknown_12303613 != 0
&$unknown_12303614 != 0
&$unknown_12303620 >= 2
av[1][2] = 62
av[1][3] = 62
av[1][4] != 0
av[1][1] = 126
joblist->j_link->j_jid <= nextjob - 1
((char*)$unknown_12303618)[8] <= nextjob - 1
*av[1] = 45
strlen(av[1]) > 4
*av[2] != 45
*$unknown_12303618 = joblist
joblist->j_link != *$unknown_12303618
pvmtoplvl != 0
$input_12 = &$unknown_12303620
$input_12 >= 2
$input_724988 = 0
Postconditions
((char*)*$unknown_12303618)[24]' = &$heap_447901
ac' = ac - 1
app' = 1
av' = av + 4
count' = &$unknown_12303620
fd' = &$heap_447900 - 4096
flags' = 99
$heap_447900' is allocated by open
$heap_447900' is allocated
$heap_447901' = &$heap_447900 - 4096
bytes_after(&$heap_447901)' = 1028
$heap_447901' is allocated by fopen
$heap_447901' is allocated
bytes_before(&$heap_447901)' = 0
jp' = *$unknown_12303618
nextjob' = nextjob + 1
oflg' = 1
ofn' = av[1] + 4
tflg' = 0
tfn' = 0
tids' = 0
where' = av[1] + 2




Change Warning 525.29316 : Integer Overflow of Allocation Size

Priority:
State:
Finding:
Owner:
Note: