Text   |  XML   |  ReML   |   Visible Warnings:

Null Test After Dereference  at editcap.c:415

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

set_rel_time

(/home/sate/Testcases/c/cve/wireshark-1.2.0/editcap.c)expand/collapse
Show more  
 361  set_rel_time(char *optarg)
 362  {
 363    char *frac, *end;
 364    long val;
 365    size_t frac_digits;
 366   
 367    if (!optarg)
 368      return;
 369   
 370    /* skip leading whitespace */
 371    while (*optarg == ' ' || *optarg == '\t') {
 372        optarg++;
 373    }
 374   
 375    /* ignore negative adjustment  */
 376    if (*optarg == '-') {
 377        optarg++;
 378    }
 379   
 380    /* collect whole number of seconds, if any */
 381    if (*optarg == '.') {         /* only fractional (i.e., .5 is ok) */
 382        val  = 0;
 383        frac = optarg;
 384    } else {
 385        val = strtol(optarg, &frac, 10);
 386        if (frac == NULL || frac == optarg || val == LONG_MIN || val == LONG_MAX) {
 387            fprintf(stderr, "1: editcap: \"%s\" isn't a valid rel time value\n",
 388                    optarg);
 389            exit(1);
 390        }
 391        if (val < 0) {            /* implies '--' since we caught '-' above  */
 392            fprintf(stderr, "2: editcap: \"%s\" isn't a valid rel time value\n",
 393                    optarg);
 394            exit(1);
 395        }
 396    }
 397    relative_time_window.secs = val;
 398   
 399    /* now collect the partial seconds, if any */
 400    if (*frac != '\0') {             /* chars left, so get fractional part */
 401      val = strtol(&(frac[1]), &end, 10);
 402      if (*frac != '.' || end == NULL || end == frac 
 403          || val < 0 || val > ONE_BILLION || val == LONG_MIN || val == LONG_MAX) {
 404        fprintf(stderr, "3: editcap: \"%s\" isn't a valid rel time value\n",
 405                optarg);
 406        exit(1);
 407      }
 408    }
 409    else {
 410      return;                     /* no fractional digits */
 411    }
 412   
 413    /* adjust fractional portion from fractional to numerator 
 414     * e.g., in "1.5" from 5 to 500000000 since .5*10^9 = 500000000 */
 415    if (frac && end) {            /* both are valid */
 416      frac_digits = end - frac - 1;   /* fractional digit count (remember '.') */
 417      while(frac_digits < 9) {    /* this is frac of 10^9 */
 418        val *= 10;
 419        frac_digits++;
 420      }
 421    }
 422    relative_time_window.nsecs = val;
 423  }
Show more  




Change Warning 4954.30034 : Null Test After Dereference

Priority:
State:
Finding:
Owner:
Note: