diff options
| author | Ronan Desplanques <ronan.desplanques@gmail.com> | 2022-05-23 09:57:10 +0200 |
|---|---|---|
| committer | Ronan Desplanques <ronan.desplanques@gmail.com> | 2022-05-23 10:09:31 +0200 |
| commit | cacdb54953dbc81eecf4c3a55c132836e7849098 (patch) | |
| tree | 7a80756ecc96318efed70b2be2bda9d1d43f28f4 | |
| parent | 5a85469500acea3b797b9b2ddc5d86a3b00c647a (diff) | |
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.
| -rw-r--r-- | apt-pkg/contrib/fileutl.cc | 2 |
1 files changed, 1 insertions, 1 deletions
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 /*{{{*/ |
