Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Null Pointer Dereference  at cmds.c:1331

Categories: LANG.MEM.NPD CWE:476
Warning ID: 48.29289
Similar Warnings: 48.28633
Procedure: parsehost
Trace: view
Modified: Thu Nov 26 11:36:49 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 parsehost
 1285 parsehost(buf, hp) 
 1286         char *buf;
 1287         struct hostd *hp;
 1288 {
 1289         char *av[10];           /* parsed words */ 
 1290         int ac;
 1291         int err = 0;
 1292  
 1293         ac = sizeof(av)/sizeof(av[0]);
 1294         if (acav(buf, &ac, av)) {
 1295                 printf("parsehost(): line too long\n");
 1296                 goto bad;
 1297         }
 1298         if (!ac)
 1299                 goto bad;
 1300  
 1301         /* Initialize Host Struct Fields */ 
 1302  
 1303         hp->hd_name = (char *) NULL;
 1304         hp->hd_arch = (char *) NULL;
 1305         hp-> = (char *) NULL;
 1306         hp->hd_dpath = (char *) NULL;
 1307         hp->hd_epath = (char *) NULL;
 1308         hp->hd_bpath = (char *) NULL;
 1309         hp->hd_wdir = (char *) NULL;
 1310         hp->hd_sopts = (char *) NULL;
 1311         hp->hd_vmid = (char *) NULL;
 1312  
 1313         /* add options to host descriptor */ 
 1314  
 1315         while (--ac > 0) {
 1316                 if (!strncmp(av[ac], "lo=", 3)) {
 1317                         if (hp->)
 1318                                 MY_FREE(hp->);
 1319                         hp-> = STRALLOC(av[ac] + 3);   /* Null Pointer Dereference (ID: 50.29291) */
 1320                         continue;
 1321                 }
 1322                 if (!strncmp(av[ac], "dx=", 3)) {
 1323                         if (hp->hd_dpath)
 1324                                 MY_FREE(hp->hd_dpath);
 1325                         hp->hd_dpath = STRALLOC(av[ac] + 3);   /* Null Pointer Dereference (ID: 49.29290) */
 1326                         continue;
 1327                 }
 1328                 if (!strncmp(av[ac], "ep=", 3)) {
 1329                         if (hp->hd_epath)
 1330                                 MY_FREE(hp->hd_epath);
true1331                         hp->hd_epath = STRALLOC(av[ac] + 3);     /* Null Pointer Dereference */
 1332                         continue;
 1333                 }
 1334                 if (!strncmp(av[ac], "sp=", 3)) {
 1335                         hp->hd_speed = atoi(av[ac] + 3);
 1336                         /* hp->hd_flag |= HF_SPEED; */ 
 1337                         continue;
 1338                 }
 1339                 if (!strncmp(av[ac], "bx=", 3)) {
 1340                         if (hp->hd_bpath)
 1341                                 MY_FREE(hp->hd_bpath);
 1342                         hp->hd_bpath = STRALLOC(av[ac] + 3);   /* Null Pointer Dereference (ID: 47.29288) */
 1343                         continue;
 1344                 }
 1345                 if (!strncmp(av[ac], "wd=", 3)) {
 1346                         if (hp->hd_wdir)
 1347                                 MY_FREE(hp->hd_wdir);
 1348                         hp->hd_wdir = STRALLOC(av[ac] + 3);   /* Null Pointer Dereference (ID: 46.29287) */
 1349                         continue;
 1350                 }
 1351                 if (!strncmp(av[ac], "so=", 3)) {
 1352                         if (hp->hd_sopts)
 1353                                 MY_FREE(hp->hd_sopts);
 1354                         hp->hd_sopts = STRALLOC(av[ac] + 3);   /* Null Pointer Dereference (ID: 45.29286) */
 1355                         continue;
 1356                 }
 1357                 if (!strncmp(av[ac], "ip=", 3)) {
 1358                         if (hp->hd_aname)
 1359                                 MY_FREE(hp->hd_aname);
 1360                         hp->hd_aname = STRALLOC(av[ac] + 3);   /* Null Pointer Dereference (ID: 44.29285) */
 1361                         continue;
 1362                 }
 1363                 if (!strncmp(av[ac], "id=", 3)) {
 1364                         if (hp->hd_vmid)
 1365                                 MY_FREE(hp->hd_vmid);
 1366                         hp->hd_vmid = STRALLOC(av[ac] + 3);   /* Null Pointer Dereference (ID: 43.29284) */
 1367                         continue;
 1368                 }
 1369                 printf("parsehost(): unknown option \"%s\"\n", av[ac]);
 1370                 err++;
Preconditions
&$unknown_12216400 != 0
*buf != 0
strlen(buf) != 0
strlen(av[1]) = 3
Postconditions
ac' = 1
$unknown_12216400' is freed
codesonar_distance_tweak' = 2
errno' != 0




Change Warning 48.29289 : Null Pointer Dereference

Because they are very similar, this warning shares annotations with warning 48.28633.
CodeSonar has selected warning 48.28633 to represent this group of similar warnings. In order to edit this group, you must edit warning 48.28633.