This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
64bit segfault in cygcheck
- From: Peter Rosin <peda at lysator dot liu dot se>
- To: cygwin-developers at cygwin dot com
- Date: Thu, 28 Mar 2013 16:20:25 +0100
- Subject: 64bit segfault in cygcheck
Hi!
I did a "cygcheck -svc", mostly for fun, and got a segfault. A gbd
session puts the blame on cygcheck.cc:671, which currently has this:
670: struct tm *tm = localtime ((const time_t *) &(ed->timestamp));
671: if (tm->tm_year < 60)
672: tm->tm_year += 2000;
The reproducer I have is:
$ cygcheck -v /bin/cygruby191.dll
Segmentation fault
$
So, since I'm not set up to build my own cygwin dll (not
comfortably anyway), I will try a blind patch and leave the
testing of it to someone else.
I haven't researched what's up with that dll, and why localtime()
would fail, but checking the return value is the right thing to do
regardless if there are other issues.
Cheers,
Peter
Index: cygcheck.cc
===================================================================
RCS file: /cvs/src/src/winsup/utils/cygcheck.cc,v
retrieving revision 1.137
diff -u -r1.137 cygcheck.cc
--- cygcheck.cc 21 Jan 2013 16:28:27 -0000 1.137
+++ cygcheck.cc 28 Mar 2013 15:08:29 -0000
@@ -668,16 +668,19 @@
ExpDirectory *ed = (ExpDirectory *) exp;
int ofs = ed->name_rva - export_rva;
struct tm *tm = localtime ((const time_t *) &(ed->timestamp));
- if (tm->tm_year < 60)
+ if (tm && tm->tm_year < 60)
tm->tm_year += 2000;
- if (tm->tm_year < 200)
+ if (tm && tm->tm_year < 200)
tm->tm_year += 1900;
printf ("%*c", lvl + 2, ' ');
- printf ("\"%s\" v%d.%d ts=", exp + ofs,
+ printf ("\"%s\" v%d.%d", exp + ofs,
ed->major_ver, ed->minor_ver);
- printf ("%d/%d/%d %d:%02d\n",
- tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
- tm->tm_hour, tm->tm_min);
+ if (tm)
+ printf (" ts=%d/%d/%d %d:%02d\n",
+ tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min);
+ else
+ printf ("\n");
}
}