lftp-4.0.9-date_fmt.patch 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. diff -up lftp-4.2.1/src/Http.cc.date_fmt lftp-4.2.1/src/Http.cc
  2. --- lftp-4.2.1/src/Http.cc.date_fmt 2011-03-25 15:35:42.000000000 +0100
  3. +++ lftp-4.2.1/src/Http.cc 2011-03-30 14:40:54.170096624 +0200
  4. @@ -29,6 +29,7 @@
  5. #include <errno.h>
  6. #include <stdarg.h>
  7. #include <time.h>
  8. +#include <limits.h>
  9. #include <fnmatch.h>
  10. #include <locale.h>
  11. #include <assert.h>
  12. @@ -565,15 +566,10 @@ void Http::SendRequest(const char *conne
  13. (long long)((limit==FILE_END || limit>entity_size ? entity_size : limit)-1),
  14. (long long)entity_size);
  15. }
  16. - if(entity_date!=NO_DATE)
  17. + if(entity_date!=NO_DATE && entity_date>0L && entity_date<INT_MAX)
  18. {
  19. - static const char weekday_names[][4]={
  20. - "Sun","Mon","Tue","Wed","Thu","Fri","Sat"
  21. - };
  22. - const struct tm *t=gmtime(&entity_date);
  23. - const char *d=xstring::format("%s, %2d %s %04d %02d:%02d:%02d GMT",
  24. - weekday_names[t->tm_wday],t->tm_mday,month_names[t->tm_mon],
  25. - t->tm_year+1900,t->tm_hour,t->tm_min,t->tm_sec);
  26. + char d[256];
  27. + strftime(d, sizeof(d), "%a, %d %b %H:%M:%S %Y GMT", gmtime(&entity_date));
  28. Send("Last-Modified: %s\r\n",d);
  29. }
  30. break;