From cacdb54953dbc81eecf4c3a55c132836e7849098 Mon Sep 17 00:00:00 2001 From: Ronan Desplanques Date: Mon, 23 May 2022 09:57:10 +0200 Subject: Fix integer underflow in flExtension Before this patch, the expression `Res - File.length()` that was used as the length underflowed. It was very unlikely to cause any problem given the saturating behavior of the std::string constructor that's used. Replacing `Res - File.length()` with `File.length() - Res` would have worked, but omitting the last argument altogether invokes an std::string constructor which does the right thing. --- apt-pkg/contrib/fileutl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index eb5dc859d..10c656301 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -691,7 +691,7 @@ string flExtension(string File) if (Res == string::npos) return File; Res++; - return string(File,Res,Res - File.length()); + return string(File,Res); } /*}}}*/ // flNoLink - If file is a symlink then deref it /*{{{*/ -- cgit v1.2.3-70-g09d2