Fixes, from Scott Renfro, for some calls to "localtime()" that didn't
check whether the call succeeded (it doesn't always do so on Windows, for example). svn path=/trunk/; revision=3722
This commit is contained in:
parent
e574c8de6d
commit
b7255e108a
3
AUTHORS
3
AUTHORS
|
@ -646,6 +646,9 @@ Scott Renfro <scott@renfro.org> {
|
|||
"-t" flag for editcap, to adjust timestamps in frames
|
||||
SSL/TLS support
|
||||
Mergecap utility for merging capture files
|
||||
Fixes for some calls to "localtime()" that didn't check whether
|
||||
the call succeeded (it doesn't always do so on Windows, for
|
||||
example)
|
||||
}
|
||||
|
||||
Juan Toledo <toledo@users.sourceforge.net> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* column-utils.c
|
||||
* Routines for column utilities.
|
||||
*
|
||||
* $Id: column-utils.c,v 1.3 2001/04/02 10:38:26 guy Exp $
|
||||
* $Id: column-utils.c,v 1.4 2001/07/15 19:14:02 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -248,15 +248,19 @@ col_set_abs_date_time(frame_data *fd, int col)
|
|||
|
||||
then = fd->abs_secs;
|
||||
tmp = localtime(&then);
|
||||
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN,
|
||||
"%04d-%02d-%02d %02d:%02d:%02d.%04ld",
|
||||
tmp->tm_year + 1900,
|
||||
tmp->tm_mon + 1,
|
||||
tmp->tm_mday,
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
(long)fd->abs_usecs/100);
|
||||
if (tmp != NULL) {
|
||||
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN,
|
||||
"%04d-%02d-%02d %02d:%02d:%02d.%04ld",
|
||||
tmp->tm_year + 1900,
|
||||
tmp->tm_mon + 1,
|
||||
tmp->tm_mday,
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
(long)fd->abs_usecs/100);
|
||||
} else {
|
||||
fd->cinfo->col_buf[col][0] = '\0';
|
||||
}
|
||||
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
||||
}
|
||||
|
||||
|
@ -286,11 +290,15 @@ col_set_abs_time(frame_data *fd, int col)
|
|||
|
||||
then = fd->abs_secs;
|
||||
tmp = localtime(&then);
|
||||
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%04ld",
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
(long)fd->abs_usecs/100);
|
||||
if (tmp != NULL) {
|
||||
snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%04ld",
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
(long)fd->abs_usecs/100);
|
||||
} else {
|
||||
fd->cinfo->col_buf[col][0] = '\0';
|
||||
}
|
||||
fd->cinfo->col_data[col] = fd->cinfo->col_buf[col];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* to_str.h
|
||||
* Routines for utilities to convert various other types to strings.
|
||||
*
|
||||
* $Id: to_str.c,v 1.9 2001/07/13 00:27:51 guy Exp $
|
||||
* $Id: to_str.c,v 1.10 2001/07/15 19:14:02 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -411,15 +411,18 @@ abs_time_to_str(struct timeval *abs_time)
|
|||
}
|
||||
|
||||
tmp = localtime(&abs_time->tv_sec);
|
||||
sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%06ld",
|
||||
mon_names[tmp->tm_mon],
|
||||
tmp->tm_mday,
|
||||
tmp->tm_year + 1900,
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
(long)abs_time->tv_usec);
|
||||
|
||||
if (tmp) {
|
||||
sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%06ld",
|
||||
mon_names[tmp->tm_mon],
|
||||
tmp->tm_mday,
|
||||
tmp->tm_year + 1900,
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
(long)abs_time->tv_usec);
|
||||
} else {
|
||||
strncpy(cur, "Not representable", sizeof(str[0]));
|
||||
}
|
||||
return cur;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* packet-diameter.c
|
||||
* Routines for DIAMETER packet disassembly
|
||||
*
|
||||
* $Id: packet-diameter.c,v 1.23 2001/06/18 02:17:45 guy Exp $
|
||||
* $Id: packet-diameter.c,v 1.24 2001/07/15 19:14:00 guy Exp $
|
||||
*
|
||||
* Copyright (c) 2001 by David Frascone <dave@frascone.com>
|
||||
*
|
||||
|
@ -702,12 +702,16 @@ static gchar *rd_value_to_str(e_avphdr *avph, const u_char *input, int length)
|
|||
#endif
|
||||
case DIAMETER_TIME:
|
||||
{
|
||||
struct tm lt;
|
||||
struct tm *lt;
|
||||
intval=pntohl(input);
|
||||
intval -= NTP_TIME_DIFF;
|
||||
lt=*localtime((time_t *)&intval);
|
||||
strftime(buffer, 1024,
|
||||
"%a, %d %b %Y %H:%M:%S %z",<);
|
||||
lt=localtime((time_t *)&intval);
|
||||
if (lt != NULL) {
|
||||
strftime(buffer, 1024,
|
||||
"%a, %d %b %Y %H:%M:%S %z",lt);
|
||||
} else {
|
||||
strncpy(buffer, "Not representable", 1024);
|
||||
}
|
||||
}
|
||||
default:
|
||||
/* Do nothing */
|
||||
|
|
14
packet-ntp.c
14
packet-ntp.c
|
@ -2,7 +2,7 @@
|
|||
* Routines for NTP packet dissection
|
||||
* Copyright 1999, Nathan Neulinger <nneul@umr.edu>
|
||||
*
|
||||
* $Id: packet-ntp.c,v 1.28 2001/06/18 02:17:50 guy Exp $
|
||||
* $Id: packet-ntp.c,v 1.29 2001/07/15 19:14:00 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -236,10 +236,14 @@ ntp_fmt_ts(const guint8 *reftime, char* buff)
|
|||
} else {
|
||||
temptime = tempstmp - (guint32) NTP_BASETIME;
|
||||
bd = gmtime(&temptime);
|
||||
fractime = bd->tm_sec + tempfrac / 4294967296.0;
|
||||
snprintf(buff, NTP_TS_SIZE, "%04d-%02d-%02d %02d:%02d:%07.4f UTC",
|
||||
bd->tm_year + 1900, bd->tm_mon + 1, bd->tm_mday,
|
||||
bd->tm_hour, bd->tm_min, fractime);
|
||||
if (bd != NULL) {
|
||||
fractime = bd->tm_sec + tempfrac / 4294967296.0;
|
||||
snprintf(buff, NTP_TS_SIZE, "%04d-%02d-%02d %02d:%02d:%07.4f UTC",
|
||||
bd->tm_year + 1900, bd->tm_mon + 1, bd->tm_mday,
|
||||
bd->tm_hour, bd->tm_min, fractime);
|
||||
} else {
|
||||
strncpy(buff, "Not representable", NTP_TS_SIZE);
|
||||
}
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* In particular I have not had an opportunity to see how it
|
||||
* responds to SRVLOC over TCP.
|
||||
*
|
||||
* $Id: packet-srvloc.c,v 1.24 2001/06/18 02:17:53 guy Exp $
|
||||
* $Id: packet-srvloc.c,v 1.25 2001/07/15 19:14:00 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -193,12 +193,16 @@ dissect_authblk(tvbuff_t *tvb, int offset, proto_tree *tree)
|
|||
|
||||
seconds = tvb_get_ntohl(tvb, offset) - 2208988800ul;
|
||||
stamp = gmtime(&seconds);
|
||||
floatsec = stamp->tm_sec + tvb_get_ntohl(tvb, offset + 4) / 4294967296.0;
|
||||
proto_tree_add_text(tree, tvb, offset, 8,
|
||||
"Timestamp: %04d-%02d-%02d %02d:%02d:%07.4f UTC",
|
||||
stamp->tm_year + 1900, stamp->tm_mon + 1,
|
||||
stamp->tm_mday, stamp->tm_hour, stamp->tm_min,
|
||||
floatsec);
|
||||
if (stamp != NULL) {
|
||||
floatsec = stamp->tm_sec + tvb_get_ntohl(tvb, offset + 4) / 4294967296.0;
|
||||
proto_tree_add_text(tree, tvb, offset, 8,
|
||||
"Timestamp: %04d-%02d-%02d %02d:%02d:%07.4f UTC",
|
||||
stamp->tm_year + 1900, stamp->tm_mon + 1,
|
||||
stamp->tm_mday, stamp->tm_hour, stamp->tm_min,
|
||||
floatsec);
|
||||
} else {
|
||||
proto_tree_add_text(tree, tvb, offset, 8, "Timestamp not representable");
|
||||
}
|
||||
proto_tree_add_text(tree, tvb, offset + 8, 2, "Block Structure Desciptor: %u",
|
||||
tvb_get_ntohs(tvb, offset + 8));
|
||||
length = tvb_get_ntohs(tvb, offset + 10);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* netmon.c
|
||||
*
|
||||
* $Id: netmon.c,v 1.38 2001/07/13 00:55:58 guy Exp $
|
||||
* $Id: netmon.c,v 1.39 2001/07/15 19:14:03 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -635,14 +635,24 @@ static gboolean netmon_dump_close(wtap_dumper *wdh, int *err)
|
|||
|
||||
file_hdr.network = htoles(wtap_encap[wdh->encap]);
|
||||
tm = localtime(&netmon->first_record_time.tv_sec);
|
||||
file_hdr.ts_year = htoles(1900 + tm->tm_year);
|
||||
file_hdr.ts_month = htoles(tm->tm_mon + 1);
|
||||
file_hdr.ts_dow = htoles(tm->tm_wday);
|
||||
file_hdr.ts_day = htoles(tm->tm_mday);
|
||||
file_hdr.ts_hour = htoles(tm->tm_hour);
|
||||
file_hdr.ts_min = htoles(tm->tm_min);
|
||||
file_hdr.ts_sec = htoles(tm->tm_sec);
|
||||
file_hdr.ts_msec = htoles(netmon->first_record_time.tv_usec/1000);
|
||||
if (tm != NULL) {
|
||||
file_hdr.ts_year = htoles(1900 + tm->tm_year);
|
||||
file_hdr.ts_month = htoles(tm->tm_mon + 1);
|
||||
file_hdr.ts_dow = htoles(tm->tm_wday);
|
||||
file_hdr.ts_day = htoles(tm->tm_mday);
|
||||
file_hdr.ts_hour = htoles(tm->tm_hour);
|
||||
file_hdr.ts_min = htoles(tm->tm_min);
|
||||
file_hdr.ts_sec = htoles(tm->tm_sec);
|
||||
} else {
|
||||
file_hdr.ts_year = htoles(1900 + 0);
|
||||
file_hdr.ts_month = htoles(0 + 1);
|
||||
file_hdr.ts_dow = htoles(0);
|
||||
file_hdr.ts_day = htoles(0);
|
||||
file_hdr.ts_hour = htoles(0);
|
||||
file_hdr.ts_min = htoles(0);
|
||||
file_hdr.ts_sec = htoles(0);
|
||||
}
|
||||
file_hdr.ts_msec = htoles(netmon->first_record_time.tv_usec/1000);
|
||||
/* XXX - what about rounding? */
|
||||
file_hdr.frametableoffset = htolel(netmon->frame_table_offset);
|
||||
file_hdr.frametablelength =
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* ngsniffer.c
|
||||
*
|
||||
* $Id: ngsniffer.c,v 1.64 2001/07/06 00:17:36 guy Exp $
|
||||
* $Id: ngsniffer.c,v 1.65 2001/07/15 19:14:03 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
||||
|
@ -1204,11 +1204,16 @@ static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
if (priv->first_frame) {
|
||||
priv->first_frame=FALSE;
|
||||
tm = localtime(&phdr->ts.tv_sec);
|
||||
start_date = (tm->tm_year - (1980 - 1900)) << 9;
|
||||
start_date |= (tm->tm_mon + 1) << 5;
|
||||
start_date |= tm->tm_mday;
|
||||
/* record the start date, not the start time */
|
||||
priv->start = phdr->ts.tv_sec - (3600*tm->tm_hour + 60*tm->tm_min + tm->tm_sec);
|
||||
if (tm != NULL) {
|
||||
start_date = (tm->tm_year - (1980 - 1900)) << 9;
|
||||
start_date |= (tm->tm_mon + 1) << 5;
|
||||
start_date |= tm->tm_mday;
|
||||
/* record the start date, not the start time */
|
||||
priv->start = phdr->ts.tv_sec - (3600*tm->tm_hour + 60*tm->tm_min + tm->tm_sec);
|
||||
} else {
|
||||
start_date = 0;
|
||||
priv->start = 0;
|
||||
}
|
||||
|
||||
/* "sniffer" version ? */
|
||||
maj_vers = 4;
|
||||
|
|
Loading…
Reference in New Issue