Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Format String  at cons.c:451

Categories: POSIX.FMT CWE:134
Warning ID: 2981.3067
Similar Warnings: 2981.3068
Procedure: main
Trace: View
Modified: Wed Sep 2 12:55:30 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     
LineSource
  /u1/paul/SATE/2010/c/pvm/pvm3/console/cons.c
  Enter main
290 main(argc, argv) 
291         int argc;
292         char **argv;
293 {
294         static struct timeval more_msgs = { 0, 0 };
295         char cmd[1024];
296         int cc;
297         int i;
298         int src, cod, len;
299         char *p;
300         FILE *ff;
301 #ifdef FDSETNOTSTRUCT 
302         fd_set rfds, fds;
303 #else 
304         struct fd_set rfds, fds; 
305 #endif 
306         int nfds;
307         int n;
308         int *np = 0;
309         struct pvmminfo minfo;
310         struct timeval *timeout;
311         int more;
312         int ac;
313         char *av[128];
314  
315 #ifdef WIN32 
316  
317         /* WSAStartup has to be called before any socket command */ 
318         /* can be executed. Why ? Ask Bill */ 
  ...
355                         fprintf(stderr,  
356                                 "SET CYGWIN=tty   (Cygwin B20)\n");
357                         fprintf(stderr,  
358                                 "SET CYGWIN32=tty (Cygwin B19)\n");
359                         exit(1);
360                 }
361         }               
362  
363 #endif 
364  
365         pvm_setopt(PvmResvTids, 1);
366  
367         aliases = TALLOC(1, struct alias, "alias");
368         BZERO((char*)aliases, sizeof(struct alias));   /* Null Pointer Dereference (ID: 2910.2982) */
369         aliases->a_link = aliases->a_rlink = aliases;
370  
371         if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'd')
372                 pvm_setopt(PvmDebugMask, pvmstrtoi(argv[1] + 2));
373  
374         pvm_setopt(PvmRoute, PvmDontRoute);
375  
376         pvm_setopt(PvmSelfTraceTid, -1);
377         pvm_setopt(PvmSelfOutputTid, -1);
378  
379         i = pvm_setopt(PvmAutoErr, 0);
380         cc = pvm_start_pvmd(argc - 1, argv + 1, 1);
381         if (cc < 0) {
382                 if (cc != PvmDupHost) {
383                         pvm_perror("Console");
384                         exit(1);
385                 }
386                 printf("pvmd already running.\n");
387         }
388         pvm_setopt(PvmAutoErr, i);
389  
390         if ((mytid = pvm_mytid()) < 0)
391                 exit(1);
392  
393         (void)signal(SIGINT, SIG_IGN);
394         /* (void)signal(SIGTERM, SIG_IGN); now PvmNoReset */ 
395  
396 #ifndef WIN32   /* NT console problem - original NT codes had commented out */ 
397         pvm_setopt( PvmNoReset, 1 );
398         pvm_setopt( PvmTraceOptions, PvmTraceFull );
399         pvm_setopt( PvmTraceBuffer, 0 );
400 #endif 
401         job_init();
402  
403         /* set default trace mask to xpvm */ 
404         sprintf(cmd, "trace xpvm");
405         ac = sizeof(av)/sizeof(av[0]) - 1;
406         if (!acav(cmd, &ac, av) && ac)
407                 trace_cmd(ac, av);
408  
409         pvm_notify(PvmHostAdd, HostsAddedTag, -1, (int*)0);
410  
411         BZERO(&minfo, sizeof(minfo));
412         minfo.src = -1;
413         minfo.ctx = -1;
414         minfo.tag = MyExitTag;
415  
416 #ifndef WIN32   /* NT console problem - original NT codes had commented out */ 
417         pvm_addmhf(minfo.src, minfo.tag, minfo.ctx, exit_handler);
418         pvm_notify(PvmTaskExit, MyExitTag, 1, &mytid);
419 #endif 
420  
421         if (!(p = getenv("HOME")))
422                 p = ".";
423         sprintf(cmd, "%s/.pvmrc", p);
424         if (ff = fopen(cmd, "r")) {
425                 while (fgets(cmd, sizeof(cmd)-1, ff))
426                         docmd(cmd);
427                 (void)fclose(ff);
428         }
429  
430         FD_ZERO(&rfds);
431  
432 #ifndef WIN32 
433         FD_SET(0, &rfds);
434 #endif 
435  
436         nfds = 1;
437         i = pvm_setopt(PvmAutoErr, 0);
438         if (pvm_getfds(&np) > 0) {
439                 FD_SET(np[0], &rfds);
440                 nfds = np[0] + 1;
441         }
442         pvm_setopt(PvmAutoErr, i);
443  
444         trc_init();
445  
446 #ifdef HASREADLINE 
447         rl_attempted_completion_function =
448                         (CPPFunction *) command_completion;
449         rl_callback_handler_install( prompt, rl_got_line ); 
450 #else 
451         printf(prompt);     /* Format String */
452         fflush(stdout);
453 #endif 
454  
455 #ifdef WIN32 
456         hStdin = GetStdHandle(STD_INPUT_HANDLE); 
457 #endif 
458  
459         while (1) {
460  
461         /*
462         * flush task stdout and trace events 
463         */ 
464  
465                 if (mytid > 0)
466                         more = checkmsgs();
467                 else 
468                         more = 0;
469  
470                 if ( more )
471                         timeout = &more_msgs;
472  
473                 else 
474 #ifndef WIN32 
475                         timeout = (struct timeval *) NULL;
476 #else 
477                         timeout = &zerotimeout; 
478 #endif 
479  
480         /*
481         * wait for command or more output 
482         */ 
483                 fds = rfds;
484                 if ((n = select(nfds,
485 #ifdef  FDSETISINT 
486                                 (int *)&fds, (int *)0, (int *)0, 
487 #else 
488                                 (fd_set *)&fds, (fd_set *)0, (fd_set *)0,
489 #endif 
490                                 timeout)) 
491                 == -1) {
492                         perror("select");
493 #ifndef WIN32 
494                         continue;
495 #endif 
496                 }  
497  
498 #ifdef WIN32 
499                 else 
500                         if (n != 0) printf("select: returned untouched data \n"); 
501 #endif 
502  
503 #ifdef WIN32 
504                 if (WAIT_TIMEOUT == WaitForSingleObject(hStdin,2000))
505                         continue; /* no input */ 
506 #else   
507                 if (n > 0 && FD_ISSET(0, &fds)) {
508 #endif 
509  
510 #ifdef HASREADLINE 
511                         rl_callback_read_char(); 
512 #else 
513                         if ((n = read(0, cmd, sizeof(cmd)-1)) < 1) {
514                                 printf("quit\n");
515                                 quit_cmd();
516                         }
517                         cmd[n] = 0;
518                         docmd(cmd);
519                         printf(prompt);   /* Format String (ID: 2981.3068) */
520                         fflush(stdout);
521 #endif 
522  
523 #ifndef WIN32 
524                 }
525 #endif 
526  
527         }
528 




Change Warning 2981.3067 : Format String

Because they are very similar, this warning shares annotations with warning 2981.3068.

Priority:
State:
Finding:
Owner:
Note: