[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#73985: fix: charset.max_char may be used before being set
From: |
Eli Zaretskii |
Subject: |
bug#73985: fix: charset.max_char may be used before being set |
Date: |
Sat, 09 Nov 2024 11:12:22 +0200 |
> Cc: 73985@debbugs.gnu.org
> Date: Thu, 24 Oct 2024 17:42:36 +0300
> From: Eli Zaretskii <eliz@gnu.org>
>
> > Thanks. You are right that the original code is incorrect, but the
> > code you propose has a subtle problem: the sum
> >
> > i + charset.code_offset
> >
> > could overflow. So we need to find a safer way of explaining the
> > problem.
>
> I fixed that (on the master branch) like this:
>
> diff --git a/src/charset.c b/src/charset.c
> index e8d0826..f7d80cc 100644
> --- a/src/charset.c
> +++ b/src/charset.c
> @@ -1007,7 +1007,8 @@ DEFUN ("define-charset-internal",
> Fdefine_charset_internal,
>
> i = CODE_POINT_TO_INDEX (&charset, charset.max_code);
> if (MAX_CHAR - charset.code_offset < i)
> - error ("Unsupported max char: %d", charset.max_char);
> + error ("Unsupported max char: %d + %ud > MAX_CHAR (%d)",
> + i, charset.max_code, MAX_CHAR);
> charset.max_char = i + charset.code_offset;
> i = CODE_POINT_TO_INDEX (&charset, charset.min_code);
> charset.min_char = i + charset.code_offset;
No further comments, so I'm now closing this bug.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#73985: fix: charset.max_char may be used before being set,
Eli Zaretskii <=