Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Leak  at cmds.c:2306

Categories: LANG.ALLOC.LEAK CWE:401 CWE:771 CWE:773
Warning ID: 2929.3011
Procedure: spawn_cmd
Trace: View
Modified: Wed Sep 2 12:52:56 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
   /u1/paul/SATE/2010/c/pvm/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: 2426.2451) */
 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: 2427.2452) */
 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: 2428.2453) */
 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 ) {
referenced by returned value2305                                         fd = open( ofn,
 2306                                                 O_RDWR|O_APPEND|O_CREAT|O_EXCL|O_TRUNC, 0600 );     /* Leak */
 2307                                 }
 2308                                 else {
 2309                                         fd = openofn, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600 );   /* Leak (ID: 2930.3012) */
 2310                                 }
referenced by fd2311                                 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  
 2327         tids = TALLOC(count > 1 ? count : 1, int, "int");
 2328         if ((i = pvm_spawn(av[1], &av[2], flags, where, count, tids)) >= 0) {
 2329                 if (oflg & !i)
 2330                         job_free(jp);
   ...
 2332                         job_free(jp2);
 2333                 printf("%d successful\n", i);
 2334                 for (i = 0; i < count; i++)
 2335                         if (tids[i] < 0)   /* Null Pointer Dereference (ID: 2932.3014) */
 2336                                 printf("%s\n", PVMERRMSG(tids[i]));
 2337                         else 
 2338                                 printf("t%x\n", tids[i]);
 2339         }
 2340         MY_FREE(tids);   /* Free Null Pointer (ID: 2931.3013) */
 2341         return 0;
 2342 } 
Preconditions
$param_1 >= 3
((char*)&((char*)*$param_2)[8])[2] = 62
((char*)&((char*)*$param_2)[8])[3] = 62
((char*)&((char*)*$param_2)[8])[4] != 0
((char*)&((char*)*$param_2)[8])[1] = 126
joblist->j_link->j_jid = nextjob
joblist->j_link->j_obufs = 0
((char*)*$param_2)[16] != 45
((char*)*$param_2)[8] = 45
strlen(((char*)$param_2)[8]) != 0
strlen(((char*)$param_2)[8]) != 2
strlen(((char*)$param_2)[8]) != 3
strlen(((char*)$param_2)[8]) != 4
strlen(((char*)$param_2)[8]) != 1
Postconditions
joblist->j_link->j_link->j_rlink' = joblist->j_link->j_rlink
joblist->j_link->j_ff' = 0
joblist->j_link->j_rlink' = 0
joblist->j_link->j_rlink->j_link' = joblist->j_link->j_link
joblist->j_link->j_link' = 0
*joblist->j_link' is freed
*stderr' is allocated by fopen
bytes_before(stderr)' = 0
errno' != 0
nextjob' = nextjob + 1




Change Warning 2929.3011 : Leak

Priority:
State:
Finding:
Owner:
Note: