diff options
| author | Guillem Jover <guillem@debian.org> | 2019-03-06 03:52:10 +0100 |
|---|---|---|
| committer | Guillem Jover <guillem@debian.org> | 2019-03-24 03:30:12 +0100 |
| commit | dcd19c7820e0294245837ee9e8beec9244ea3b2d (patch) | |
| tree | ab70b5e39066dbf133be14be1ff1f453d6212ca4 /lib | |
| parent | a1f9ccf08ddc99e4e3f1ead01abb6a8d8d506b3a (diff) | |
| download | dpkg-dcd19c7820e0294245837ee9e8beec9244ea3b2d.tar.gz | |
libdpkg: Use ERANGE instead of EINVAL for tar_atol8() out-of-range error
We should use the correct errno value, otherwise the error string makes
little sense, and ends up being very confusing.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/dpkg/t/t-tar.c | 8 | ||||
| -rw-r--r-- | lib/dpkg/tarfn.c | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/dpkg/t/t-tar.c b/lib/dpkg/t/t-tar.c index 8417ed306..6fa217de5 100644 --- a/lib/dpkg/t/t-tar.c +++ b/lib/dpkg/t/t-tar.c @@ -72,22 +72,22 @@ test_tar_atol8(void) errno = 0; u = tar_atoul(" 11111aaa ", 12, UINTMAX_MAX); test_pass(u == 0); - test_pass(errno == EINVAL); + test_pass(errno == ERANGE); errno = 0; u = tar_atoul(" 8 ", 12, UINTMAX_MAX); test_pass(u == 0); - test_pass(errno == EINVAL); + test_pass(errno == ERANGE); errno = 0; u = tar_atoul(" 18 ", 12, UINTMAX_MAX); test_pass(u == 0); - test_pass(errno == EINVAL); + test_pass(errno == ERANGE); errno = 0; u = tar_atoul(" aa ", 12, UINTMAX_MAX); test_pass(u == 0); - test_pass(errno == EINVAL); + test_pass(errno == ERANGE); } static void diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c index 7ccdae389..a0821f217 100644 --- a/lib/dpkg/tarfn.c +++ b/lib/dpkg/tarfn.c @@ -110,7 +110,7 @@ tar_atol8(const char *s, size_t size) if (*s == '\0' || *s == ' ') break; if (*s < '0' || *s > '7') - return tar_ret_errno(EINVAL, 0); + return tar_ret_errno(ERANGE, 0); n = (n * 010) + (*s++ - '0'); } |
