| From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
|---|---|
| To: | Andreas Seltenreich <andreas(dot)seltenreich(at)credativ(dot)de> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: [PATCH] Add error handling to byteaout. |
| Date: | 2015-06-03 16:32:38 |
| Message-ID: | 20150603163238.GL2988@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Andreas Seltenreich wrote:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>
> > Andreas Seltenreich <andreas(dot)seltenreich(at)credativ(dot)de> writes:
> >> The scary one is due to an integer overflow the attached patch also
> >> fixes.
> >
> > s/int/Size/ doesn't fix anything on 32-bit machines.
>
> Well, it changes the signedness of the computation on 32-bit, and in
> combination with the fact that "len" is always smaller than 2^32, but
> may exceed 2^31-1, the change avoids the dependency on the undefined
> behavior of signed integer overflows in C on 32-bit as well.
Why not just use an unsigned 64 bit variable? Also, perhaps
palloc_huge() avoids the whole problem in the first place ... though it
might only move the issue around, if you cannot ship the longer-than-1GB
resulting escaped value. (Of course, if you try to allocate 2 GB in a
32 bit machine, you're going to be having quite some fun ...)
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2015-06-03 16:43:03 | Re: anole: assorted stability problems |
| Previous Message | Piotr Stefaniak | 2015-06-03 16:23:24 | Re: [PATCH] Add error handling to byteaout. |