From Jim Young via bug 4162:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 25 Oct 2009 20:18:24 +0000 (20:18 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 25 Oct 2009 20:18:24 +0000 (20:18 +0000)
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.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@30698 f5534014-38df-0310-8fa8-9805f1628bb7

editcap.c

index 5937cbac372002b503d656fb924689004909fb1e..2cbf2387f02a6e31745edcdf88d825a6264c67c2 100644 (file)
--- a/editcap.c
+++ b/editcap.c
@@ -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",