[ libetpan-Bugs-2892730 ] Crash on Windows during message_id computation
"SourceForge.net" <[email protected]> Fri, 06 Nov 2009 08:59:50 +0000
| Newsgroups | gmane.mail.libetpan.user |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #2892730, was opened at 2009-11-05 18:10
Message generated for change (Comment added) made by smarinier
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=429696&aid=2892730&group_id=41064
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: other
Group: Latest stable - libEtPan!
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Sergey Perminov (perminov)
Assigned to: Nobody/Anonymous (nobody)
Summary: Crash on Windows during message_id computation
Initial Comment:
low-level/imf/mailimf_types_helper.c file, mailimf_get_message_id function:
1271 char * mailimf_get_message_id(void)
1272 {
1273 char id[MAX_MESSAGE_ID];
1274 time_t now;
1275 char name[MAX_MESSAGE_ID];
1276 long value;
1277
1278 now = time(NULL);
1279 value = random();
1280
1281 gethostname(name, MAX_MESSAGE_ID);
1282 snprintf(id, MAX_MESSAGE_ID, "etPan.%lx.%lx.%x@%s",
1283 now, value, getpid(), name);
1284
1285 return strdup(id);
1286 }
On Windows time_t is 8 byte long type.
In case you pass 8 instead of 4 bytes into snprintf function,
windows runtime crashes with "memory access violation"
Environment:
Compiled under VS2008SP1
As a fix it's possible to use long instead of time_t:
--- mailimf_types_helper.c.orig 2009-11-05 21:06:34.000000000 +0300
+++ mailimf_types_helper.c 2009-11-05 21:07:08.000000000 +0300
@@ -1271,11 +1271,11 @@
char * mailimf_get_message_id(void)
{
char id[MAX_MESSAGE_ID];
- time_t now;
+ long now;
char name[MAX_MESSAGE_ID];
long value;
- now = time(NULL);
+ now = (long)time(NULL);
value = random();
gethostname(name, MAX_MESSAGE_ID);
----------------------------------------------------------------------
Comment By: Sebastien Marinier (smarinier)
Date: 2009-11-06 09:59
Message:
I think it would be better to allow all the time_t for the library to
"work" (until 18 Jan 2038 ;) ) and to handle the 64 bits mode also.
This would give, according to me, in build-windows/StdAfx.h :
#if !defined(_WIN64)
# define _USE_32BIT_TIME_T
#endif
Could you check this ?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=429696&aid=2892730&group_id=41064
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july