Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Buffer Overrun  at pvmd.c:1733

Categories: LANG.MEM.BO CWE:120 CWE:121 CWE:122 CWE:126
Warning ID: 22089.28936
Procedure: work
Trace: view
Modified: Thu Nov 26 11:28:57 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 main
$input_177908 >= ( 8 * bytes_after(&$heap_290327) - 31 ) / 32947 main(argc, argv) 
 948         int argc;
 949         char **argv;
 950 {
 951         int i, j;
$input_177932 >= ( 8 * bytes_after(&$heap_290361) - 31 ) / 32952         char *name = "";
 953         struct passwd *pe;
 954         int testmode = 0;
 955         struct timeval tnow;
 956         char buf[128];
 957  
 958 #ifndef WIN32 
 959         /* check for extension config options */ 
$input_177956 >= ( 8 * bytes_after(&$heap_290395) - 31 ) / 32960         check_ext_input();
 961  
 962         /* make sure 0, 1, 2 are in use */ 
$input_178556 >= ( 8 * bytes_after(&$heap_291245) - 31 ) / 32963         (void)open("/dev/null", O_RDONLY, 0);
$input_178700 >= ( 8 * bytes_after(&$heap_291446) - 31 ) / 32964         (void)open("/dev/null", O_RDONLY, 0);   /* File System Race Condition (ID: 272.28943) */
$input_178844 >= ( 8 * bytes_after(&$heap_291641) - 31 ) / 32965         (void)open("/dev/null", O_RDONLY, 0);   /* File System Race Condition (ID: 272.28942) */
 966 #else 
 967         /* WSAStartup has to be called before any socket command */ 
 968         /* can be executed. Why ? Ask Bill   */ 
 969  
 970         if (WSAStartup(0x0101, &WSAData) != 0) {
 971               printf("\nWSAStartup() failed\n");
 972               ExitProcess(1);
 973         }
 974         setsockopt(INVALID_SOCKET,SOL_SOCKET,SO_OPENTYPE,
 975                         (char *)&nAlert,sizeof(int));
 976         osinfo=malloc(sizeof(OSVERSIONINFO));
 977         osinfo->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 978         GetVersionEx(osinfo);
 979         os_is_NT= ( osinfo->dwPlatformId == VER_PLATFORM_WIN32_NT); 
 980 #endif 
 981  
 982         {
 983                 char *p;
$input_178988 >= ( 8 * bytes_after(&$heap_291833) - 31 ) / 32984                 if (p = getenv("PVMDDEBUG"))
 985                         pvmdebmask = pvmstrtoi(p);
 986         }
 987  
 988 #ifndef WIN32 
$input_179108 >= ( 8 * bytes_after(&$heap_291993) - 31 ) / 32989         if ((pvm_useruid = getuid()) == -1) {
 990                 pvmlogerror("main() can't getuid()\n");
 991                 pvmbailout(0);
 992         }
$input_179204 >= ( 8 * bytes_after(&$heap_292121) - 31 ) / 32993         pvmchkuid( pvm_useruid );
 994 #else 
 995         username = MyGetUserName(); 
 996 #endif 
 997  
$input_179300 >= ( 8 * bytes_after(&$heap_292249) - 31 ) / 32998         pvmsetlog(3);
 999  
 1000 #ifndef WIN32 
$input_179492 >= ( 8 * bytes_after(&$heap_292505) - 31 ) / 321001         if (pe = getpwuid(pvm_useruid))
$input_179612 >= ( 8 * bytes_after(&$heap_292665) - 31 ) / 321002                 username = STRALLOC(pe->pw_name);   /* Null Pointer Dereference (ID: 271.28941) */
 1003         else 
 1004                 pvmlogerror("main() can't getpwuid\n");
$input_179948 >= ( 8 * bytes_after(&$heap_293105) - 31 ) / 321005         endpwent();
 1006 #endif 
 1007  
 1008 #ifdef WIN32 
 1009         if ((pvmmyupid = getpid()) == -1) {
 1010                 pvmlogerror("main() can't getpid() %d \n",GetLastError());
 1011                 pvmbailout(0);
 1012         } 
 1013 #else 
$input_179972 >= ( 8 * bytes_after(&$heap_293136) - 31 ) / 321014         if ((pvmmyupid = getpid()) == -1) {
 1015                 pvmlogerror("main() can't getpid()\n");
 1016                 pvmbailout(0);
 1017         }
 1018 #endif 
 1019  
$input_180044 >= ( 8 * bytes_after(&$heap_293229) - 31 ) / 321020         (void)pvmgetroot();             /* fail here if we can't */ 
 1021  
$input_180236 >= ( 8 * bytes_after(&$heap_293477) - 31 ) / 321022         sprintf(buf, "PVM_ARCH=%s", myarchname);
$input_180332 >= ( 8 * bytes_after(&$heap_293601) - 31 ) / 321023         pvmputenv(STRALLOC(buf));   /* Null Pointer Dereference (ID: 270.28940) */
 1024  
$input_180956 >= ( 8 * bytes_after(&$heap_294387) - 31 ) / 321025         pvmmydsig = pvmgetdsig();
 1026  
$input_181148 >= ( 8 * bytes_after(&$heap_294627) - 31 ) / 321027         ppi_config(argc, argv);
 1028  
 1029 #if defined(IMA_PGON) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 1030                 || defined(IMA_AIX5SP2) || defined(IMA_BEOLIN) 
 1031         mpp_init(&argc, argv); 
 1032 #endif 
 1033  
$input_181292 >= ( 8 * bytes_after(&$heap_294807) - 31 ) / 321034         for (i = j = 1; i < argc; i++) {
$input_181388 >= ( 8 * bytes_after(&$heap_294927) - 31 ) / 321035                 if (argv[i][0] == '-') {
$input_181412 >= ( 8 * bytes_after(&$heap_294957) - 31 ) / 321036                         switch (argv[i][1]) {
 1037  
 1038                         case 'd': 
 1039                                 pvmdebmask = pvmstrtoi(argv[i] + 2);
 1040                                 break;
 1041  
 1042                         case 'n': 
 1043                                 name = argv[i] + 2;
 1044                                 break;
 1045  
$input_181436 >= ( 8 * bytes_after(&$heap_294987) - 31 ) / 321046                         case 'S': 
$input_181460 >= ( 8 * bytes_after(&$heap_295017) - 31 ) / 321047                                 argv[j++] = argv[i];
 1048                         case 's': 
$input_181580 >= ( 8 * bytes_after(&$heap_295167) - 31 ) / 321049                                 slavemode = 1;
$input_181604 >= ( 8 * bytes_after(&$heap_295197) - 31 ) / 321050                                 break;
 1051  
 1052                         case 't': 
 1053                                 testmode = 1;
 1054                                 break;
 1055  
 1056 #ifdef WIN32 
 1057                         case 'u':
 1058                                 if (os_is_NT==FALSE) {
 1059                                         /* someone is on win95 ... */ 
 1060                                         argv[i]++;argv[i]++;
 1061                                         strcpy(username,argv[i]);
 1062                                 }
 1063                                 else 
 1064                                         if (strcmp(strcat("-u",username),argv[i])) {
   ...
 1066                                                                 "Provided Username(%s) does not match ",
 1067                                                                 username);
 1068                                                 fprintf(stderr,"with OS (%s).\n",
 1069                                                                 argv[i]);
 1070                                                 fprintf(stderr,"Wrong rshd ?!\n");
 1071                                                 exit(1);
 1072                                 }
 1073                                 break; 
 1074 #endif 
 1075  
 1076                         default: 
 1077                                 argv[j++] = argv[i];
 1078                         }
 1079  
 1080                 } else {
 1081                         argv[j++] = argv[i];
 1082                 }
 1083         }
$input_181676 >= ( 8 * bytes_after(&$heap_295287) - 31 ) / 321084         argc = j;
 1085  
$input_181700 >= ( 8 * bytes_after(&$heap_295317) - 31 ) / 321086         if (pvmdebmask) {
$input_181724 >= ( 8 * bytes_after(&$heap_295347) - 31 ) / 321087                 pvmlogprintf("version %s\n", PVM_VER);
$input_183092 >= ( 8 * bytes_after(&$heap_297027) - 31 ) / 321088                 pvmlogprintf("ddpro %d tdpro %d\n", DDPROTOCOL, TDPROTOCOL);
$input_185172 >= ( 8 * bytes_after(&$heap_299607) - 31 ) / 321089                 pvmlogprintf("main() debug mask is 0x%x (%s)\n",
$input_184788 >= ( 8 * bytes_after(&$heap_299127) - 31 ) / 321090                                 pvmdebmask, debug_flags(pvmdebmask));
 1091         }
 1092  
$input_186884 >= ( 8 * bytes_after(&$heap_301737) - 31 ) / 321093         if (!*name) {
$input_186908 >= ( 8 * bytes_after(&$heap_301767) - 31 ) / 321094                 if (gethostname(buf, sizeof(buf)-1) == -1) {
 1095                         pvmlogerror("main() can't gethostname()\n");
 1096                         pvmbailout(0);
 1097                 }
$input_187028 >= ( 8 * bytes_after(&$heap_301917) - 31 ) / 321098                 name = buf;
 1099         }
$input_187052 >= ( 8 * bytes_after(&$heap_301947) - 31 ) / 321100         if (testmode) {
 1101                 PVM_TIMET time_temp;
 1102                 gettimeofday(&tnow, (struct timezone*)0);
 1103                 pvmlogprintf("version %s ddpro %d tdpro %d sdpro %d\n",
 1104                                 PVM_VER, DDPROTOCOL, TDPROTOCOL, SDPROTOCOL);
 1105                 time_temp = (PVM_TIMET) tnow.tv_sec;
 1106                 pvmlogprintf(ctime(&time_temp));   /* Format String (ID: 22202.29377) */
 1107                 for (i = 0; i < argc; i++)
 1108                         pvmlogprintf("argv[%d]=\"%s\"\n", i, argv[i]);
 1109                 exit(0);
 1110         }
 1111  
 1112         {
 1113                 char *p;
$input_187076 >= ( 8 * bytes_after(&$heap_301977) - 31 ) / 321114                 if (p = getenv("PVM_MAX_TASKS")) {
 1115                         pvm_max_ntasks = atoi(p);
 1116                         if (pvm_max_ntasks < 0)
 1117                                 pvm_max_ntasks = 0;
 1118                 }
 1119         }
 1120  
$input_187196 >= ( 8 * bytes_after(&$heap_302127) - 31 ) / 321121         if (slavemode)                                  /* slave pvmd */ 
$input_187220 >= ( 8 * bytes_after(&$heap_302157) - 31 ) / 321122                 slave_config(name, argc, argv);
 1123  
 1124         else                                                    /* master pvmd */ 
 1125                 master_config(name, argc, argv);
 1126  
 1127 #if TTYDIS & 8 
 1128         setsid(); 
 1129 #endif 
 1130 #if TTYDIS & 4 
 1131         setpgid(0, 0); 
 1132 #endif 
 1133 #if TTYDIS & 2 
 1134         setpgrp(0, 0); 
 1135 #endif 
 1136 #if TTYDIS & 1 
 1137         if ((i = open("/dev/tty", O_RDWR, 0)) != -1) {
 1138                 (void)ioctl(i, TIOCNOTTY, 0);
 1139                 (void)close(i);
 1140         } 
 1141 #endif 
 1142  
 1143         myhostpart = hosts->ht_local << (ffs(tidhmask) - 1);
 1144         pvmmytid = myhostpart | TIDPVMD;
 1145  
 1146         ndead = 1000;   /* XXX hum, static limit makes this easy to do */ 
 1147  
 1148         /* deads = TALLOC(ndead, int, "pids"); */ 
 1149  
 1150         deads = TALLOC(ndead, struct deaddata, "dead");
 1151         BZERO((char*)deads, ndead * sizeof(struct deaddata));   /* Null Pointer Dereference (ID: 22090.28937) */
 1152  
 1153 #ifndef WIN32 
 1154         /* no signaling in win32 because no parent child relation ... :-( */ 
 1155  
 1156 #ifndef IMA_I860 /* this signal interferes with getcube() on I860 */ 
 1157 #ifdef  SYSVSIGNAL 
 1158 #ifndef IMA_BEOSCYLD 
 1159         (void)signal(SIGCLD, reap);
 1160 #endif 
 1161 #ifdef IMA_SUNMP 
 1162         sigset(SIGCLD, reap); /* yep we go really want to catch our kids */ 
 1163 #endif 
 1164 #else 
 1165         (void)signal(SIGCHLD, reap); 
 1166 #endif  /* SYSVSIGNAL */ 
 1167 #endif /*IMA_I860*/ 
 1168  
 1169 #endif 
 1170  
 1171         if (signal(SIGINT, SIG_IGN) != SIG_IGN)
 1172 #ifdef WIN32 
 1173                 (void)signal(SIGINT, (void*) catch); 
 1174 #else 
 1175                 (void)signal(SIGINT, catch);
 1176 #endif 
 1177  
 1178         if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
 1179 #ifdef WIN32 
 1180         (void)signal(SIGTERM, (void *) catch); 
 1181 #else 
 1182         (void)signal(SIGTERM, catch);
 1183 #endif 
 1184  
 1185 #ifndef WIN32 
 1186         (void)signal(SIGHUP, SIG_IGN);
 1187         (void)signal(SIGPIPE, SIG_IGN);
 1188 #endif 
 1189  
 1190 #ifndef WIN32 
 1191         (void)signal(SIGFPE, evilsig);
 1192         (void)signal(SIGILL, evilsig);
 1193 #else 
 1194         (void)signal(SIGFPE, (void *)evilsig);
 1195         (void)signal(SIGILL, (void *)evilsig); 
 1196 #endif 
 1197  
 1198 #ifdef  SIGBUS 
 1199         (void)signal(SIGBUS, evilsig);
 1200 #endif 
 1201  
 1202 #ifndef WIN32 
 1203         (void)signal(SIGSEGV, evilsig);
 1204 #else 
 1205         (void)signal(SIGSEGV, (void *)evilsig); 
 1206 #endif 
 1207  
 1208 #ifdef  SIGSYS 
 1209         (void)signal(SIGSYS, evilsig);
 1210 #endif 
 1211  
 1212 #ifdef  SIGDANGER 
 1213         (void)signal(SIGDANGER, biteme); 
 1214 #endif 
 1215  
 1216 #ifdef  STATISTICS 
 1217         reset_statistics();
 1218 #endif 
 1219  
 1220         task_init();
 1221         wait_init(myhostpart, TIDLOCAL);
 1222         mb_init();
 1223         ppi_init();
 1224  
 1225         opq = pk_new(0);
 1226         opq->pk_tlink = opq->pk_trlink = opq;
 1227  
 1228         /* print local socket address on stdout in case someone cares */ 
 1229  
 1230         if (!slavemode) {
 1231                 printf("%s\n", getenv("PVMSOCK"));
 1232                 fflush(stdout);
 1233         }
 1234  
 1235 /* XXX hack to start slaves automatically */ 
 1236  
 1237         if (!slavemode && filehosts) {
 1238                 struct hostd *hp;
 1239                 int hh;
 1240                 int n = 0;
 1241  
 1242                 for (hh = filehosts->ht_last; hh >= 1; hh--)
 1243                         if ((hp = filehosts->ht_hosts[hh]) && !(hp->hd_flag & HF_NOSTART))
 1244                                 n++;
 1245                 if (n) {
 1246                         addmesg = mesg_new(0);
 1247                         addmesg->m_tag = DM_ADD;   /* Null Pointer Dereference (ID: 269.28934) */
 1248                         pkint(addmesg, n);
 1249                         for (hh = 1; hh <= filehosts->ht_last; hh++)
 1250                                 if ((hp = filehosts->ht_hosts[hh]) && !(hp->hd_flag & HF_NOSTART))
 1251                                         pkstr(addmesg, hp->hd_name);
 1252                         addmesg->m_dst = TIDPVMD;
 1253                 }
 1254         }
 1255  
hosts->ht_local >= ( 8 * bytes_after(hosts->ht_hosts) - 31 ) / 321256         work();
     Enter main / 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 */  /* Buffer Underrun (ID: 22088.28935) */
 1734                                   myarchname,
hosts->ht_local >= ( 8 * bytes_after(hosts->ht_hosts) - 31 ) / 321735                                   PVM_VER);
     Exit main / work
Preconditions
$param_1 >= 3
&$unknown_795722 != -1
&$unknown_795722 != 0
&$unknown_795724 != 0
((char*)*$param_2)[20] != 58
atnewline = 0
buf[0] != 0
buf[0] != 61
locltasks != 0
myfmt != -1
pvmdlogmax <= log_alrdy
pvmmytid != 0
rd != 0
waitlist = 0
Postconditions
*stdin' is allocated by fopen
bytes_before(stdin)' = 0
*stdout' is allocated by fopen
bytes_before(stdout)' = 0
PASSWD_COUNTER' = 0
$unknown_795735' is allocated by malloc
buf[0]' = 0
strlen(&buf[0])' = 0
strlen(&buf[0])' = 17
buf[17]' = 0
deads' = &$heap_307040
debugger' = &$unknown_795735
epaths' = &$heap_307035
errno' != 0
$heap_307009' is allocated by open
$heap_307009' is allocated
$heap_307010' is allocated by open
$heap_307010' is allocated
$heap_307011' is allocated by malloc
$heap_307011' is allocated
bytes_before(&$heap_307011)' = 0
strlen(&$heap_307011)' = strlen(stored_passwd)'
tocttou($heap_307011)' = tocttou(*stored_passwd.pw_name)
$heap_307012' = buf[0]
bytes_after(&$heap_307012)' = strlen(myarchname) + 10
$heap_307012' is allocated by malloc
$heap_307012' is allocated
bytes_before(&$heap_307012)' = 0
strlen(&$heap_307012)' = strlen(myarchname) + 9
tocttou($heap_307012)' = tocttou(buf)
$heap_307013' = 1
bytes_after(&$heap_307013)' = 32
$heap_307013' is allocated by malloc
$heap_307013' is allocated
bytes_before(&$heap_307013)' = 0
((char*)&$heap_307013)[16]' = $input_12
((char*)&$heap_307013)[20]' = $input_188292
((char*)&$heap_307013)[28]' = &$heap_307014
((char*)&$heap_307013)[12]' = $input_12
$heap_307014' = 0
$heap_307014' is allocated
bytes_before(&$heap_307014)' = 0
$heap_307035' is allocated by malloc
$heap_307035' is allocated
bytes_before(&$heap_307035)' = 0
$heap_307040' = 0
bytes_after(&$heap_307040)' = 24000
$heap_307040' is allocated by malloc
$heap_307040' is allocated
bytes_before(&$heap_307040)' = 0
$heap_307041' = &$heap_307041
bytes_after(&$heap_307041)' = 48
$heap_307041' is allocated by malloc
$heap_307041' is allocated
bytes_before(&$heap_307041)' = 0
((char*)&$heap_307041)[4]' = &$heap_307041
$heap_307042' = &$heap_307042
bytes_after(&$heap_307042)' = 120
$heap_307042' is allocated by malloc
$heap_307042' is allocated
bytes_before(&$heap_307042)' = 0
((char*)&$heap_307042)[16]' = 0
((char*)&$heap_307042)[20]' = 0
((char*)&$heap_307042)[4]' = &$heap_307042
((char*)&$heap_307042)[8]' = &$heap_307042
((char*)&$heap_307042)[116]' = 0
((char*)&$heap_307042)[12]' = &$heap_307042
hosts' = &$heap_307013
i' = argc
log_fd' = -1
name' = &buf[0]
ndead' = 1000
opq' = &$heap_307042
p' = 0
p' = 0
pe' = &stored_passwd.pw_name
pvm_useruid' = &$unknown_795722
pvmdebmask' = &$unknown_795724
pvmmboxclasses' = 0
pvmmydsig' = myfmt
pvmmyupid' != -1
runstate' = 3
slavemode' = 1
stats.selneg' = 0
testmode' = 0
username' = &$heap_307011
waitlist' = &$heap_307041
widbase' = myhostpart'
widrange' = 262143




Change Warning 22089.28936 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: