[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 0/9] strtol(3)-related fixes
From: |
Alejandro Colomar |
Subject: |
[PATCH v3 0/9] strtol(3)-related fixes |
Date: |
Fri, 15 Mar 2024 15:24:10 +0100 |
Hi Branden,
Here's a patch set that includes the patches that Dave reminded, the
ceil_prime() one, and the fixes for the problems I noticed in your
recent commit.
I've rebased everything on top of git HEAD. Below is a range-diff.
Have a lovely day!
Alex
Alejandro Colomar (9):
[libgroff]: Remove redundant checks.
[libgroff]: Remove dead code
src/: Remove redundant checks after strtol(3).
[grolbp]: Remove bogus (and redundant) check
src/: ceil_prime(): Add function to get the lowest prime not smaller
than n
[indxbib]: Don't else after [[noreturn]]
[indxbib]: Clear errno before calling strtol(3)
[indxbib]: Remove dead code
[indxbib]: Collapse related tests
src/devices/grodvi/dvi.cpp | 4 ++--
src/devices/grolbp/lbp.cpp | 4 ++--
src/devices/grolj4/lj4.cpp | 6 +++---
src/devices/grops/ps.cpp | 4 ++--
src/devices/grops/psrm.cpp | 2 +-
src/include/lib.h | 2 +-
src/libs/libbib/index.cpp | 4 +---
src/libs/libgroff/curtime.cpp | 3 +--
src/libs/libgroff/font.cpp | 2 +-
src/libs/libgroff/prime.cpp | 18 +++++++++++++++++-
src/preproc/eqn/lex.cpp | 2 +-
src/preproc/pic/tex.cpp | 2 +-
src/preproc/refer/command.cpp | 3 +--
src/preproc/refer/ref.cpp | 2 +-
src/preproc/refer/refer.cpp | 6 +++---
src/utils/indxbib/indxbib.cpp | 27 ++++++++-------------------
src/utils/lkbib/lkbib.cpp | 2 +-
src/utils/lookbib/lookbib.cpp | 2 +-
src/utils/tfmtodit/tfmtodit.cpp | 5 +----
19 files changed, 49 insertions(+), 51 deletions(-)
Range-diff against v2:
1: bd017c14b ! 1: 1ade0b95a [libgroff]: Remove redundant checks.
@@ Commit message
ERANGE can only happen if strtol(3) returns either LONG_MIN or
LONG_MAX.
+ Link: <https://savannah.gnu.org/bugs/?65451>
+ Cc: "G. Branden Robinson" <branden@debian.org>
+ Cc: Dave Kemper <saint.snit@gmail.com>
+ Cc: "James K. Lowden" <jklowden@schemamania.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
## src/libs/libgroff/curtime.cpp ##
2: 6cbaf842e ! 2: b00a34743 [libgroff]: Remove dead code
@@ Commit message
strtol(3) can only report ERANGE, if the base is valid (and it is).
+ Link: <https://savannah.gnu.org/bugs/?65451>
+ Cc: "G. Branden Robinson" <branden@debian.org>
+ Cc: Dave Kemper <saint.snit@gmail.com>
+ Cc: "James K. Lowden" <jklowden@schemamania.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
## src/libs/libgroff/curtime.cpp ##
3: bb5c66245 ! 3: b16590405 src/: Remove redundant checks after strtol(3).
@@ Commit message
`str == end` can only happen if strtol(3) returns 0.
+ Link: <https://savannah.gnu.org/bugs/?65451>
+ Cc: "G. Branden Robinson" <branden@debian.org>
+ Cc: Dave Kemper <saint.snit@gmail.com>
+ Cc: "James K. Lowden" <jklowden@schemamania.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
## src/devices/grodvi/dvi.cpp ##
@@ src/preproc/refer/refer.cpp: int main(int argc, char **argv)
## src/utils/indxbib/indxbib.cpp ##
@@ src/utils/indxbib/indxbib.cpp: static void check_integer_arg(char opt,
const char *arg, int min, int *res)
- {
- char *ptr;
- long n = strtol(arg, &ptr, 10);
-- if (n == 0 && ptr == arg)
-+ if (ptr == arg)
- error("argument to -%1 not an integer", opt);
+ if (ERANGE == errno)
+ fatal("argument to -%1 must be between %2 and %3", arg, min,
+ INT_MAX);
+- else if (n == 0 && ptr == arg)
++ else if (ptr == arg)
+ fatal("argument to -%1 not an integer", opt);
else if (n < min)
- error("argument to -%1 must not be less than %2", opt, min);
+ fatal("argument to -%1 must not be less than %2", opt, min);
## src/utils/lkbib/lkbib.cpp ##
@@ src/utils/lkbib/lkbib.cpp: int main(int argc, char **argv)
4: 2f913d604 ! 4: be068e3e4 [grolbp]: Remove bogus (and redundant) check
@@ Commit message
`str == end` can only happen if strtol(3) returns 0.
+ Closes: <https://savannah.gnu.org/bugs/?65451>
+ Cc: "G. Branden Robinson" <branden@debian.org>
+ Cc: Dave Kemper <saint.snit@gmail.com>
+ Cc: "James K. Lowden" <jklowden@schemamania.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
## src/devices/grolbp/lbp.cpp ##
5: 9432f7f87 ! 5: 3157b9dd4 src/: ceil_prime(): Add function to get the
lowest prime not smaller than n
@@ Commit message
While at it, fix the logic, which was incorrect in the open-coded call
sites, since for an input of 1, it produced 3, but the first prime is
2.
+ A recent commit started rejecting 1 earlier, so this bug was now
+ impossible to trigger, but remained there.
Also, since this is a library function, let's behave well for an input
- of 0, and return also the first prime, 2.
+ of 0, which is mathematically fine, and return also the first prime, 2.
+ Link: <https://savannah.gnu.org/bugs/?65452>
+ Link: <https://lists.gnu.org/archive/html/groff/2024-03/msg00065.html>
Cc: "G. Branden Robinson" <branden@debian.org>
+ Cc: Dave Kemper <saint.snit@gmail.com>
+ Cc: "James K. Lowden" <jklowden@schemamania.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
## src/include/lib.h ##
@@ src/utils/indxbib/indxbib.cpp
@@ src/utils/indxbib/indxbib.cpp: int main(int argc, char **argv)
{
int requested_hash_table_size;
- check_integer_arg('h', optarg, 1, &requested_hash_table_size);
+ check_integer_arg('h', optarg, 2, &requested_hash_table_size);
- hash_table_size = requested_hash_table_size;
- if ((hash_table_size > 2) && (hash_table_size % 2) == 0)
- hash_table_size++;
-: --------- > 6: f51a4b177 [indxbib]: Don't else after [[noreturn]]
-: --------- > 7: 0212f9790 [indxbib]: Clear errno before calling strtol(3)
-: --------- > 8: 2bc3edd6a [indxbib]: Remove dead code
-: --------- > 9: 06d68f407 [indxbib]: Collapse related tests
--
2.43.0
signature.asc
Description: PGP signature
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, (continued)
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, Alejandro Colomar, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, G. Branden Robinson, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, Alejandro Colomar, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, James K. Lowden, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, G. Branden Robinson, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, James K. Lowden, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, Alejandro Colomar, 2024/03/13
[PATCH v3 2/9] [libgroff]: Remove dead code, Alejandro Colomar, 2024/03/15
[PATCH v3 3/9] src/: Remove redundant checks after strtol(3)., Alejandro Colomar, 2024/03/15
[PATCH v3 4/9] [grolbp]: Remove bogus (and redundant) check, Alejandro Colomar, 2024/03/15
[PATCH v3 0/9] strtol(3)-related fixes,
Alejandro Colomar <=
- [PATCH v4 00/10] strtol(3)-related fixes, Alejandro Colomar, 2024/03/16
- [PATCH v4 01/10] [libgroff]: Remove redundant checks., Alejandro Colomar, 2024/03/16
- [PATCH v4 02/10] [libgroff]: Remove dead code, Alejandro Colomar, 2024/03/16
- [PATCH v4 03/10] src/: Remove redundant checks after strtol(3)., Alejandro Colomar, 2024/03/16
- [PATCH v4 04/10] [grolbp]: Remove bogus (and redundant) check, Alejandro Colomar, 2024/03/16
- [PATCH v4 05/10] src/: ceil_prime(): Add function to get the lowest prime not less than n, Alejandro Colomar, 2024/03/16
- [PATCH v4 06/10] [indxbib]: Don't else after [[noreturn]], Alejandro Colomar, 2024/03/16
- [PATCH v4 07/10] [indxbib]: Clear errno before calling strtol(3), Alejandro Colomar, 2024/03/16
- [PATCH v4 10/10] [grolbp]: Fix range check after strtol(3), Alejandro Colomar, 2024/03/16
- Re: [PATCH v4 10/10] [grolbp]: Fix range check after strtol(3), Alejandro Colomar, 2024/03/16