Text   |  XML   |  ReML   |   Visible Warnings:

Null Test After Dereference  at editcap.c:350

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

set_time_adjustment

(/home/sate/Testcases/c/cve/wireshark-1.2.0/editcap.c)expand/collapse
Show more  
 295  set_time_adjustment(char *optarg)
 296  {
 297    char *frac, *end;
 298    long val;
 299    size_t frac_digits;
 300   
 301    if (!optarg)
 302      return;
 303   
 304    /* skip leading whitespace */
 305    while (*optarg == ' ' || *optarg == '\t') {
 306        optarg++;
 307    }
 308   
 309    /* check for a negative adjustment */
 310    if (*optarg == '-') {
 311        time_adj.is_negative = 1;
 312        optarg++;
 313    }
 314   
 315    /* collect whole number of seconds, if any */
 316    if (*optarg == '.') {         /* only fractional (i.e., .5 is ok) */
 317        val  = 0;
 318        frac = optarg;
 319    } else {
 320        val = strtol(optarg, &frac, 10);
 321        if (frac == NULL || frac == optarg || val == LONG_MIN || val == LONG_MAX) {
 322            fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n",
 323                    optarg);
 324            exit(1);
 325        }
 326        if (val < 0) {            /* implies '--' since we caught '-' above  */
 327            fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n",
 328                    optarg);
 329            exit(1);
 330        }
 331    }
 332    time_adj.tv.tv_sec = val;
 333   
 334    /* now collect the partial seconds, if any */
 335    if (*frac != '\0') {             /* chars left, so get fractional part */
 336      val = strtol(&(frac[1]), &end, 10);
 337      if (*frac != '.' || end == NULL || end == frac 
 338          || val < 0 || val > ONE_MILLION || val == LONG_MIN || val == LONG_MAX) {
 339        fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n",
 340                optarg);
 341        exit(1);
 342      }
 343    }
 344    else {
 345      return;                     /* no fractional digits */
 346    }
 347   
 348    /* adjust fractional portion from fractional to numerator 
 349     * e.g., in "1.5" from 5 to 500000 since .5*10^6 = 500000 */
 350    if (frac && end) {            /* both are valid */
 351      frac_digits = end - frac - 1;   /* fractional digit count (remember '.') */
 352      while(frac_digits < 6) {    /* this is frac of 10^6 */
 353        val *= 10;
 354        frac_digits++;
 355      }
 356    }
 357    time_adj.tv.tv_usec = val;
 358  }
Show more  




Change Warning 4951.30033 : Null Test After Dereference

Priority:
State:
Finding:
Owner:
Note: