Re: overflow in snprintf() when printing INT64_MIN

2018-09-27 Thread Andres Freund
Hi, On 2018-09-27 17:34:54 -0700, Andres Freund wrote: > On 2018-09-27 20:18:12 -0400, Tom Lane wrote: > > > /* Handle +/- */ > > > if (dosign && adjust_sign((value < 0), forcesign, &signvalue); > > > uvalue = -(uint64) value; > > > else > > > uvalue = (uint64) value; > >

Re: overflow in snprintf() when printing INT64_MIN

2018-09-27 Thread Andres Freund
Hi, On 2018-09-27 20:18:12 -0400, Tom Lane wrote: > Andres Freund writes: > > I just noticed, while reviewing a patch that corrects overflow handing > > in snprintf, that we don't correctly handle INT64_MIN in snprintf.c: > > Well, you still get the right answer, even if the "-value" is > nomina

Re: overflow in snprintf() when printing INT64_MIN

2018-09-27 Thread Tom Lane
Andres Freund writes: > I just noticed, while reviewing a patch that corrects overflow handing > in snprintf, that we don't correctly handle INT64_MIN in snprintf.c: Well, you still get the right answer, even if the "-value" is nominally undefined. > I suspect the best way to fix this, would be

overflow in snprintf() when printing INT64_MIN

2018-09-27 Thread Andres Freund
Hi, I just noticed, while reviewing a patch that corrects overflow handing in snprintf, that we don't correctly handle INT64_MIN in snprintf.c: static void fmtint(int64 value, char type, int forcesign, int leftjust, int minlen, int zpad, int precision, int pointflag, PrintfT