APTのSEGVが瞬時に直された
=== modified file 'apt-pkg/acquire-item.cc' --- apt-pkg/acquire-item.cc 2011-03-14 15:27:24 +0000 +++ apt-pkg/acquire-item.cc 2011-04-02 19:00:45 +0000 @@ -841,7 +841,7 @@ if (ShortDesc().find("Translation") != 0) msg += "\nFail-Ignore: true"; struct stat Buf; - if (stat(Final.c_str(),&Buf) != 0) + if (stat(Final.c_str(),&Buf) == 0) msg += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime); return msg;
まさかIA-64関係なく,全アーキで腐ってたとは思わなかった.Debian testing AMD64のこのPCでは何事もなく動いてるんですが.
// AcqIndex::Custom600Headers - Insert custom request headers /*{{{*/ // --------------------------------------------------------------------- /* The only header we use is the last-modified header. */ string pkgAcqIndex::Custom600Headers() { string Final = _config->FindDir("Dir::State::lists"); Final += URItoFileName(RealURI); if (_config->FindB("Acquire::GzipIndexes",false)) Final += ".gz"; string msg = "\nIndex-File: true"; // FIXME: this really should use "IndexTarget::IsOptional()" but that // seems to be difficult without breaking ABI if (ShortDesc().find("Translation") != 0) msg += "\nFail-Ignore: true"; struct stat Buf; if (stat(Final.c_str(),&Buf) == 0) msg += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime); return msg; }
// TimeRFC1123 - Convert a time_t into RFC1123 format. . . /*{{{*/ // --------------------------------------------------------------------- /* This converts a time_t into a string time representation that is year 2000 complient and timezone neutral */ string TimeRFC1123(time_t Date) { struct tm Conv = *gmtime(&Date); 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"}; sprintf(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; }
うーん, struct stat
をstack上に取った後,中身を stat(2)
が更新しないままで(stat(2)
の成功を調べる条件が逆だった), time_t st_mtime
のゴミを参照してた訳だが,だからってSEGVるもんだろうか?
ともあれ,これでしばらく待てばtestingに降りてくるから,普通に aptitude update
できるようになる.