BUG #5993: pg_size_pretty overflow

From: "nicola75ss" <nicola75ss(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5993: pg_size_pretty overflow
Date: 2011-04-24 18:17:50
Message-ID: 201104241817.p3OIHoZk039649@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5993
Logged by: nicola75ss
Email address: nicola75ss(at)gmail(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Haas 2011-04-25 13:48:50 Re: BUG #5989: Assertion failure on UPDATE of big value
Previous Message Tom Lane 2011-04-23 19:53:48 Re: database introspection error