From 093e9f5d30f37164dd28d639fedfb059e105e43e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 31 May 2010 17:22:04 +0200 Subject: [PATCH 1/1] * apt-pkg/contrib/cmdline.cc: - fix segfault in SaveInConfig caused by writing over char[] sizes --- apt-pkg/contrib/cmndline.cc | 4 ++-- debian/changelog | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc index 0b16bf51a..5a9944096 100644 --- a/apt-pkg/contrib/cmndline.cc +++ b/apt-pkg/contrib/cmndline.cc @@ -360,11 +360,11 @@ bool CommandLine::DispatchArg(Dispatch *Map,bool NoMatch) than nothing after all. */ void CommandLine::SaveInConfig(unsigned int const &argc, char const * const * const argv) { - char cmdline[300]; + char cmdline[100 + argc * 50]; unsigned int length = 0; bool lastWasOption = false; bool closeQuote = false; - for (unsigned int i = 0; i < argc; ++i, ++length) + for (unsigned int i = 0; i < argc && length < sizeof(cmdline); ++i, ++length) { for (unsigned int j = 0; argv[i][j] != '\0' && length < sizeof(cmdline)-1; ++j, ++length) { diff --git a/debian/changelog b/debian/changelog index 79768a779..6341484f2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,8 +26,10 @@ apt (0.7.26~exp6) UNRELEASED; urgency=low - add a simple wrapper around std::set for packages with it - move regex magic from apt-get to new FromRegEx method - move cmdline parsing from apt-cache to new FromCommandLine method + * apt-pkg/contrib/cmdline.cc: + - fix segfault in SaveInConfig caused by writing over char[] sizes - -- David Kalnischkies Sat, 29 May 2010 19:09:05 +0200 + -- David Kalnischkies Mon, 31 May 2010 17:21:00 +0200 apt (0.7.26~exp5) experimental; urgency=low -- 2.45.2