Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Buffer Underrun  at pvmlog.c:444

Categories: LANG.MEM.BU CWE:124 CWE:127
Warning ID: 22036.28695
Procedure: vpvmlogprintf
Trace: view
Modified: Thu Nov 26 11:27:28 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/src/pvmd.c
   Enter work
 1696 work() 
 1697 {
 1698         static int lastpinged = 0;      /* host that got last keepalive msg */ 
 1699 #ifdef FDSETNOTSTRUCT 
 1700         fd_set rfds, wfds;                      /* result of select */ 
 1701         /* fd_set efds; */ 
 1702 #else 
 1703         struct fd_set rfds, wfds;       /* result of select */ 
 1704         /* struct fd_set efds; */ 
 1705 #endif 
 1706         int nrdy;                                       /* number of fds ready after select */ 
   ...
 1718         double tbpl;                            /* time at beginning of probe loop */ 
 1719         double toutpl;                          /* timeout in the probe loop */ 
 1720         int timed_out;
 1721         extern double dclock();
 1722 #endif 
 1723 #endif 
 1724 #ifdef  SHMEM 
 1725         int someclosed; 
 1726 #endif 
 1727  
 1728         gettimeofday(&tnow, (struct timezone*)0);
 1729         if (pvmdebmask || myhostpart) {
 1730                 PVM_TIMET time_temp;
 1731                 pvmlogprintf("%s (%s) %s %s\n",
 1732                                 hosts->ht_hosts[hosts->ht_local]->hd_name,
 1733                                 inadport_decimal(&hosts->ht_hosts[hosts->ht_local]->hd_sad),   /* Buffer Overrun (ID: 22089.28936) */  /* Buffer Underrun (ID: 22088.28935) */
 1734                                 myarchname,
 1735                                 PVM_VER);
 1736                 pvmlogprintf("ready ");
 1737                 time_temp = (PVM_TIMET) tnow.tv_sec;
$input_12 < 11738                 pvmlogprintf(ctime(&time_temp));   /* Format String (ID: 22201.29376) */
     /kat0/fletcher/SATE/2010/pvm3/src/pvmlog.c
     Enter work / pvmlogprintf
 458   pvmlogprintf(const char *fmt, ...) 
 459   #else 
 460   pvmlogprintf(va_alist)
 461           va_dcl 
 462   #endif 
 463   {
 464           va_list ap;
 465           int cc;
 466    
 467   #if defined (__STDC__) || defined(IMA_WIN32_WATCOM)
 468    
 469           va_start(ap, fmt);
 470   #else 
 471           char    *fmt;
 472    
 473           va_start(ap);
 474           fmt = va_arg(ap, char *); 
 475   #endif 
strlen(fmt) < -1 * bytes_before(fmt) + 1476           cc = vpvmlogprintf(fmt, ap);
       Enter work / pvmlogprintf / vpvmlogprintf
 368     vpvmlogprintf(fmt, ap) 
 369             char *fmt;
 370             va_list ap;
 371     {
 372             char vtmp[1024];
 373             char *truncated;
 374             int cnt = 0;
 375             int cc;
 376      
 377     #ifdef  TIMESTAMPLOG 
 378             time_t now;
 379             struct tm *tmp;
 380      
 381             time(&now);
 382             tmp = localtime(&now);
 383     #endif  /*TIMESTAMPLOG*/ 
 384      
 385             /* snag var arg string, in case re-use whacks it... */ 
 386             /* (thank you very much x86_64...  :-Q */ 
 387             /* damn, also need to prevent buffer overflows... */ 
 388             /* (thanks to Lasse Makholm <lasse.makholm@nokia.com> */ 
 389             /* for this patch...) */ 
 390             cc = vsnprintf(vtmp, sizeof(vtmp), fmt, ap);   /* Null Pointer Dereference (ID: 22037.28696) */  /* Null Pointer Dereference (ID: 22092.28939) */
 391             truncated = ( cc >= 0 && cc < sizeof(vtmp) )   /* Redundant Condition (ID: 20.28602) */
 392                             ? "" : "[...]\n";
 393      
 394             if (log_how & 1) {
 395                     if (atnewline) {
 396                             if (pvmmytid)
 397                                     fprintf(stderr, "[t%x] ", pvmmytid);
 398                             else 
 399                                     fprintf(stderr, "[pvmd pid%d] ", pvmmyupid);
 400      
 401     #ifdef  TIMESTAMPLOG 
 402                             fprintf(stderr, "%02d/%02d %02d:%02d:%02d ",
 403                                                     tmp->tm_mon + 1,
 404                                                     tmp->tm_mday,
       ...
 406                                                     tmp->tm_min,
 407                                                     tmp->tm_sec);
 408     #endif  /*TIMESTAMPLOG*/ 
 409                     }
 410                     /* cc = vfprintf(stderr, fmt, ap); */ 
 411                     cc = fprintf(stderr, "%s%s", vtmp, truncated);
 412                     cnt = ( cc >= 0 ) ? cnt + cc : cc;
 413                     fflush(stderr);
 414             }
 415      
 416             if (log_how & 2) {
 417                     if (log_alrdy < pvmdlogmax) {
 418                             if (atnewline) {
 419                                     if (pvmmytid)
 420                                             fprintf(log_ff, "[t%x] ", pvmmytid);
 421                                     else 
 422                                             fprintf(log_ff, "[pvmd pid%d] ", pvmmyupid);
 423      
 424     #ifdef  TIMESTAMPLOG 
 425                                     fprintf(log_ff, "%02d/%02d %02d:%02d:%02d ",
 426                                                     tmp->tm_mon + 1,
       ...
 434                             /* cc = vfprintf(log_ff, fmt, ap); */ 
 435                             cc = fprintf(log_ff, "%s%s", vtmp, truncated);
 436                             cnt = ( cnt >= 0 ) ? ( ( cc >= 0 ) ? cnt + cc : cc ) : cnt;
 437                             fflush(log_ff);
 438      
 439                             if ((log_alrdy += cnt) >= pvmdlogmax)
 440                                     (void)write(log_fd, toomuch, strlen(toomuch));
 441                     }
 442             }
 443      
strlen(fmt) < -1 * bytes_before(fmt) + 1444             atnewline = (fmt[strlen(fmt) - 1] == '\n') ? 1 : 0;     /* Buffer Underrun */  /* Buffer Underrun (ID: 22091.28938) */
       Exit work / pvmlogprintf / vpvmlogprintf
     Exit work / pvmlogprintf
Preconditions
myhostpart != 0
pvmdebmask = 0
$input_12 <= 25
$input_12 >= 0
$input_8388 <= 1023
$input_8388 >= 0
Postconditions
ap' = &__builtin_va_alist
ap' = &__builtin_va_alist
atnewline' = 1
strlen(&buf[0])' = 59
buf[59]' = 0
cc' >= 1
cc' <= 1023
cnt' = 0
ctime_buf[0]' = $input_444
strlen(&ctime_buf[0])' = $input_12
fmt' = &ctime_buf[0]
fmt' = &ctime_buf[0]
time_temp' = &$unknown_239464
tmbuf.tm_sec' = &$unknown_239468
tmp' = &tmbuf.tm_sec
tnow.tv_sec' = &$unknown_239464
truncated' = &#string5[0]
strlen(&vtmp[0])' = $input_8388




Change Warning 22036.28695 : Buffer Underrun

Priority:
State:
Finding:
Owner:
Note: