Re: overflow in snprintf() when printing INT64_MIN

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: overflow in snprintf() when printing INT64_MIN
Дата
Msg-id 24646.1538093892@sss.pgh.pa.us
обсуждение исходный текст
Ответ на overflow in snprintf() when printing INT64_MIN  (Andres Freund <andres@anarazel.de>)
Ответы Re: overflow in snprintf() when printing INT64_MIN  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
Andres Freund <andres@anarazel.de> 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 to instead do:

>     /* Handle +/- */
>     if (dosign && adjust_sign((value < 0), forcesign, &signvalue);
>         uvalue = -(uint64) value;
>     else
>         uvalue = (uint64) value;

Hm, what does -x mean for an unsigned value?  I'm not really
convinced this is conceptually better.

            regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: overflow in snprintf() when printing INT64_MIN
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [patch]overallocate memory for curly braces in array_out