diff options
author | Bill Meier <wmeier@newsguy.com> | 2011-02-25 00:40:22 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2011-02-25 00:40:22 +0000 |
commit | 39c2e1f71d3dab57aa85719378902ec1e64e0917 (patch) | |
tree | 106cfa9ca7865ba53ca108b7bddcf6786934d245 /wiretap/lanalyzer.c | |
parent | 3dc76979300a70a7c5beacc0a395704b66ab1902 (diff) |
From Robert Bullen: Fix "Potential access violation when writing to LANalyzer files"
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5698
(Note from me: Before the fix "File ! Save As" in Lanalyzer format
crashed quite consistently on my Windows 7)
svn path=/trunk/; revision=36061
Diffstat (limited to 'wiretap/lanalyzer.c')
-rw-r--r-- | wiretap/lanalyzer.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index 76d19767b8..20d2d2eb86 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -653,10 +653,22 @@ gboolean lanalyzer_dump_open(wtap_dumper *wdh, gboolean cant_seek, int *err) static gboolean lanalyzer_dump_header(wtap_dumper *wdh, int *err) { LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv); - struct tm *fT = localtime( (time_t *) &(itmp->start.tv_sec)); guint16 board_type = itmp->encap == WTAP_ENCAP_TOKEN_RING ? BOARD_325TR /* LANalyzer Board Type */ : BOARD_325; /* LANalyzer Board Type */ + time_t secs; + struct tm *fT; + + /* The secs variable is needed to work around 32/64-bit time_t issues. + itmp->start is a timeval struct, which declares its tv_sec field + (itmp->start.tv_sec) as a long (typically 32 bits). time_t can be 32 + or 64 bits, depending on the platform. Invoking as follows could + pass a pointer to a 32-bit long where a pointer to a 64-bit time_t + is expected: localtime((time_t*) &(itmp->start.tv_sec)) */ + secs = itmp->start.tv_sec; + fT = localtime(&secs); + if (fT == NULL) + return FALSE; fseek(wdh->fh, 0, SEEK_SET); |