diff options
author | Gerald Combs <gerald@wireshark.org> | 2009-10-25 20:18:24 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2009-10-25 20:18:24 +0000 |
commit | 5ba1582dda65479e99565b74a0238c23c41ce838 (patch) | |
tree | 52184b6e526f8f4d5589fa66216d1d7994e48e49 /editcap.c | |
parent | 460e086f9e100025c1528c24cc6204d542c5db8c (diff) | |
download | wireshark-5ba1582dda65479e99565b74a0238c23c41ce838.tar.gz wireshark-5ba1582dda65479e99565b74a0238c23c41ce838.tar.bz2 wireshark-5ba1582dda65479e99565b74a0238c23c41ce838.zip |
From Jim Young via bug 4162:
This patch limits the number of fractional digits used to calculate the
fractional component of editcap's -t and -w options.
Specifically this patch truncates the fractional component (if any) of the -t
and -w options to 6 and 9 respectively.
svn path=/trunk/; revision=30698
Diffstat (limited to 'editcap.c')
-rw-r--r-- | editcap.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -336,6 +336,11 @@ set_time_adjustment(char *optarg) /* now collect the partial seconds, if any */ if (*frac != '\0') { /* chars left, so get fractional part */ val = strtol(&(frac[1]), &end, 10); + /* if more than 6 fractional digits truncate to 6 */ + if((end - &(frac[1])) > 6) { + frac[7] = 't'; /* 't' for truncate */ + val = strtol(&(frac[1]), &end, 10); + } if (*frac != '.' || end == NULL || end == frac || val < 0 || val > ONE_MILLION || val == LONG_MIN || val == LONG_MAX) { fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", @@ -401,6 +406,11 @@ set_rel_time(char *optarg) /* now collect the partial seconds, if any */ if (*frac != '\0') { /* chars left, so get fractional part */ val = strtol(&(frac[1]), &end, 10); + /* if more than 9 fractional digits truncate to 9 */ + if((end - &(frac[1])) > 9) { + frac[10] = 't'; /* 't' for truncate */ + val = strtol(&(frac[1]), &end, 10); + } if (*frac != '.' || end == NULL || end == frac || val < 0 || val > ONE_BILLION || val == LONG_MIN || val == LONG_MAX) { fprintf(stderr, "3: editcap: \"%s\" isn't a valid rel time value\n", |