summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-01-25 21:29:54 -0800
committerGuy Harris <guy@alum.mit.edu>2017-01-26 06:06:30 +0000
commit1165dfc8f6b2feead7c989508f38c83f788b5afb (patch)
tree42a186c7c1ec7fbace8c482ef5238788317bebfd
parent19028ebab4f3c097c8e87d3b532b80a5c1369eae (diff)
downloadwireshark-1165dfc8f6b2feead7c989508f38c83f788b5afb.tar.gz
Make some variables 64-bit, to avoid overflows.
Assume that the relative milliseconds could be 64-bit, and make the indices calculated from it 64-bit as well. Change-Id: Ie1248c9440172b85ffbb05461ef1ee07c371fc3c Reviewed-on: https://code.wireshark.org/review/19795 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--sharkd_session.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sharkd_session.c b/sharkd_session.c
index 12a85c8c2d..e6d0c4b740 100644
--- a/sharkd_session.c
+++ b/sharkd_session.c
@@ -1335,8 +1335,8 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count)
const char *sepa = "";
unsigned int framenum;
- int idx;
- int max_idx = 0;
+ gint64 idx;
+ gint64 max_idx = 0;
if (tok_interval)
(void) ws_strtou32(tok_interval, NULL, &interval_ms);
@@ -1361,8 +1361,8 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count)
for (framenum = 1; framenum <= cfile.count; framenum++)
{
frame_data *fdata = frame_data_sequence_find(cfile.frames, framenum);
- time_t msec_rel;
- int new_idx;
+ gint64 msec_rel;
+ gint64 new_idx;
if (start_ts == NULL)
start_ts = &fdata->abs_ts;
@@ -1370,15 +1370,14 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count)
if (filter_data && !(filter_data[framenum / 8] & (1 << (framenum % 8))))
continue;
- /* TODO, make it 64-bit, to avoid msec overflow after 24days */
- msec_rel = (time_t)((fdata->abs_ts.secs - start_ts->secs) * 1000 + (fdata->abs_ts.nsecs - start_ts->nsecs) / 1000000);
+ msec_rel = (fdata->abs_ts.secs - start_ts->secs) * 1000 + (fdata->abs_ts.nsecs - start_ts->nsecs) / 1000000;
new_idx = msec_rel / interval_ms;
if (idx != new_idx)
{
if (stat.frames != 0)
{
- printf("%s[%d,%u,%" G_GUINT64_FORMAT "]", sepa, idx, stat.frames, stat.bytes);
+ printf("%s[%" G_GINT64_FORMAT ",%u,%" G_GUINT64_FORMAT "]", sepa, idx, stat.frames, stat.bytes);
sepa = ",";
}
@@ -1399,11 +1398,11 @@ sharkd_session_process_intervals(char *buf, const jsmntok_t *tokens, int count)
if (stat.frames != 0)
{
- printf("%s[%d,%u,%" G_GUINT64_FORMAT "]", sepa, idx, stat.frames, stat.bytes);
+ printf("%s[%" G_GINT64_FORMAT ",%u,%" G_GUINT64_FORMAT "]", sepa, idx, stat.frames, stat.bytes);
/* sepa = ","; */
}
- printf("],\"last\":%d,\"frames\":%u,\"bytes\":%" G_GUINT64_FORMAT "}\n", max_idx, stat_total.frames, stat_total.bytes);
+ printf("],\"last\":%" G_GINT64_FORMAT ",\"frames\":%u,\"bytes\":%" G_GUINT64_FORMAT "}\n", max_idx, stat_total.frames, stat_total.bytes);
}
/**