From 8ff84cf381c254565aa3e1837265f9991909e576 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 2 Apr 2011 17:42:01 +0200 Subject: impossible to be too long but just to be sure use snprintf --- apt-pkg/contrib/strutl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 2e2bb5ebc..ace738d7a 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -699,7 +699,7 @@ string TimeRFC1123(time_t Date) const char *Month[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul", "Aug","Sep","Oct","Nov","Dec"}; - sprintf(Buf,"%s, %02i %s %i %02i:%02i:%02i GMT",Day[Conv.tm_wday], + snprintf(Buf, sizeof(Buf), "%s, %02i %s %i %02i:%02i:%02i GMT",Day[Conv.tm_wday], Conv.tm_mday,Month[Conv.tm_mon],Conv.tm_year+1900,Conv.tm_hour, Conv.tm_min,Conv.tm_sec); return Buf; -- cgit v1.2.3 From 410327e1ee0fac0c28a95e45ea75f7359cc8dcb4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 2 Apr 2011 17:59:10 +0200 Subject: let TimeRFC1123 return an empty string if gmtime() fails --- apt-pkg/contrib/strutl.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index ace738d7a..072dda3ac 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -692,9 +692,11 @@ int StringToBool(const string &Text,int Default) year 2000 complient and timezone neutral */ string TimeRFC1123(time_t Date) { - struct tm Conv = *gmtime(&Date); - char Buf[300]; + struct tm Conv; + if (gmtime_r(&Date, &Conv) == NULL) + return ""; + char Buf[300]; const char *Day[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; const char *Month[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul", "Aug","Sep","Oct","Nov","Dec"}; -- cgit v1.2.3