X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/872b3d3983839d2d9f14268c5adf976a72ecc5ad..cce08fb5aca7dd01706cecea845b183dc62b1717:/apt-pkg/cdrom.cc diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 1b9e98519..9b0568d8f 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -1,9 +1,6 @@ /* */ -#ifdef __GNUG__ -#pragma implementation "apt-pkg/cdrom.h" -#endif #include #include #include @@ -422,6 +419,9 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) { F.getline(Buffer,sizeof(Buffer)); CurLine++; + if (F.fail() && !F.eof()) + return _error->Error(_("Line %u too long in source list %s."), + CurLine,File.c_str()); _strtabexpand(Buffer,sizeof(Buffer)); _strstrip(Buffer); @@ -535,7 +535,7 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) } if(log) { msg.str(""); - ioprintf(msg, _("Stored Label: %s \n"), + ioprintf(msg, _("Stored label: %s \n"), Database.Find("CD::"+ident).c_str()); log->Update(msg.str()); } @@ -564,7 +564,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) string DFile = _config->FindFile("Dir::State::cdroms"); if (FileExists(DFile) == true) { - if (ReadConfigFile(Database,DFile) == false) + if (ReadConfigFile(Database,DFile) == false) return _error->Error("Unable to read the cdrom database %s", DFile.c_str()); } @@ -603,7 +603,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) log->Update("["+ID+"]\n"); if(log) - log->Update(_("Scanning Disc for index files..\n"),STEP_SCAN); + log->Update(_("Scanning disc for index files..\n"),STEP_SCAN); // Get the CD structure vector List; @@ -647,8 +647,11 @@ bool pkgCdrom::Add(pkgCdromStatus *log) log->Update(msg.str(), STEP_SCAN); } - if (List.size() == 0 && SourceList.size() == 0) + if (List.size() == 0 && SourceList.size() == 0) + { + UnmountCdrom(CDROM); return _error->Error("Unable to locate any package files, perhaps this is not a Debian Disc"); + } // Check if the CD is in the database string Name; @@ -684,7 +687,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) Name.empty() == true) { if(!log) + { + UnmountCdrom(CDROM); return _error->Error("No disc name found and no way to ask for it"); + } while(true) { if(!log->AskCdromName(Name)) { @@ -714,7 +720,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) Database.Set("CD::" + ID,Name); if(log) { msg.str(""); - ioprintf(msg, _("This Disc is called: \n'%s'\n"), Name.c_str()); + ioprintf(msg, _("This disc is called: \n'%s'\n"), Name.c_str()); log->Update(msg.str()); } @@ -751,13 +757,16 @@ bool pkgCdrom::Add(pkgCdromStatus *log) // Print the sourcelist entries if(log) - log->Update(_("Source List entries for this Disc are:\n")); + log->Update(_("Source list entries for this disc are:\n")); for (vector::iterator I = List.begin(); I != List.end(); I++) { string::size_type Space = (*I).find(' '); if (Space == string::npos) + { + UnmountCdrom(CDROM); return _error->Error("Internal error"); + } if(log) { msg.str(""); @@ -771,7 +780,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) { string::size_type Space = (*I).find(' '); if (Space == string::npos) + { + UnmountCdrom(CDROM); return _error->Error("Internal error"); + } if(log) { msg.str("");