This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 64bit segfault in cygcheck


On Mar 28 16:31, Peter Rosin wrote:
> On 2013-03-28 16:20, Peter Rosin wrote:
> > 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.
> 
> Sorry for replying to self, but right after hitting send it occurred
> to me that it might be type size issue (duh!), and I believe this is
> a better patch...
> 
> int is still 32 bits, while time_t is now 64 bits, right?

That's right.  Thanks a lot for the patch.  I'll have a look later today
or tomorrow, since I'm currently hunting down my very own SEGV ;)


Corinna

> 
> 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:26:57 -0000
> @@ -667,17 +667,21 @@
>  
>  	  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)
> +	  time_t ts = ed->timestamp;
> +	  struct tm *tm = localtime (&ts);
> +	  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");
>  	}
>      }
>  
> 

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]