BUG #5993: pg_size_pretty overflow - Mailing list pgsql-bugs

From nicola75ss
Subject BUG #5993: pg_size_pretty overflow
Date
Msg-id 201104241817.p3OIHoZk039649@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #5993: pg_size_pretty overflow
List pgsql-bugs
The following bug has been logged online:

Bug reference:      5993
Logged by:          nicola75ss
Email address:      nicola75ss@gmail.com
PostgreSQL version: 8.4
Operating system:   windows 7
Description:        pg_size_pretty overflow
Details:

Good morning. I'm totally newbie with postgresql. I was studying
pg_size_pretty() and I've discovered that if I pass it a great value it
returns negative value.

This is an example

select pg_size_pretty(9223372000000000000); -- "-8388607 TB"

I've asked on stackoverflow

http://stackoverflow.com/questions/5768097/why-does-pg-size-pretty-return-ne
gative-value

and users suggest me to report this as a bug.
They say that the problem in the source code is here

else
  {
                     mult *= 1024;
                     snprintf(buf, sizeof(buf), INT64_FORMAT " TB",
                              (size + mult / 2) / mult); /* OVERFLOW! */
                 }
Regards. Nicola Cossu

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #5988: CTINE duplicates constraints
Next
From: Robert Haas
Date:
Subject: Re: BUG #5988: CTINE duplicates constraints