diff options
| author | Julian Andres Klode <jak@debian.org> | 2025-05-19 15:58:44 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2025-05-19 15:58:44 +0000 |
| commit | 49e0eec055c5feca1ff7289c0fc59306a3a67a3d (patch) | |
| tree | 00878cbd2e3e9cfa290a366550159f0a7b255ce0 | |
| parent | d0ecc3286b4487d3b3f2809c95233863bffdada5 (diff) | |
| parent | 91e8c456964d5ff4b3b7afe2f1cb074de9dfe592 (diff) | |
Merge branch 'wip/wlozano/getline-fix' into 'main'
Fix error handling with getline
See merge request apt-team/apt!265
| -rw-r--r-- | apt-pkg/contrib/fileutl.cc | 2 | ||||
| -rw-r--r-- | apt-pkg/contrib/gpgv.cc | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 4dd7b1ac3..85997275c 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1003,7 +1003,7 @@ bool StartsWithGPGClearTextSignature(string const &FileName) errno = 0; DEFER([&] { fclose(gpg); free(lineptr); }); ssize_t const result = getline(&lineptr, &n, gpg); - if (errno != 0) + if (result < 0 && errno != 0) { _error->Errno("getline", "Could not read from %s", FileName.c_str()); return false; diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc index b555331d6..0341521ac 100644 --- a/apt-pkg/contrib/gpgv.cc +++ b/apt-pkg/contrib/gpgv.cc @@ -76,7 +76,7 @@ class LineBuffer /*{{{*/ { errno = 0; line_length = getline(&buffer, &buffer_size, stream); - if (errno != 0) + if (line_length < 0 && errno != 0) return _error->Errno("getline", "Could not read from %s", InFile.c_str()); if (line_length == -1) { |
