[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overf
From: |
Bruno Haible |
Subject: |
Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows |
Date: |
Mon, 10 Nov 2003 21:37:38 +0100 |
User-agent: |
KMail/1.5 |
Paul Eggert wrote:
> This patch causes xsize.h to conflict with xalloc.h, because xalloc.h
> now uses SIZE_MAX in a preprocessor context.
Oh well. I'll add a configure-time determination of SIZE_MAX and PTRDIFF_MAX
tomorrow. And then noone will complain any more that it's not ISO C 99
compliant :-)
> +# define xalloc_oversized(n, s) ((size_t) -1 / (s) <= (n))
I think this expression is wrong, and should better be written as
((size_t) -2 / (s) < (n))
For example, take n = (SIZE_MAX - 1) / 2 and s = 2 (or vice versa).
Since n * s == (SIZE_MAX - 1) is in bounds, xalloc_oversized(n, s)
must evaluate to false.
Bruno
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows, Bruno Haible, 2003/11/03
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/03
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows, Bruno Haible, 2003/11/04
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/04
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows, Bruno Haible, 2003/11/05
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/05
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows, Bruno Haible, 2003/11/06
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/06
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows,
Bruno Haible <=
- Re: [Bug-gnulib] linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/10
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Simon Josefsson, 2003/11/19
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/19
- Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Bruno Haible, 2003/11/19
- Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/19
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Simon Josefsson, 2003/11/19
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Simon Josefsson, 2003/11/19
- Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, James Youngman, 2003/11/19
- Re: [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/19
- [Bug-gnulib] Re: linebreak.c proposed patches for size-calculation overflows, Paul Eggert, 2003/11/19