X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/872b3d3983839d2d9f14268c5adf976a72ecc5ad..f8477782df203e1998a8704e71a1a3cc699e9e3a:/apt-pkg/cdrom.cc diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 1b9e98519..ce1beb39b 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -422,6 +422,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 +538,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 +567,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 +606,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 +650,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 +690,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 +723,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 +760,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 +783,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("");