Unix Technical Forum

potential integer overflow in md.c

This is a discussion on potential integer overflow in md.c within the pgsql Bugs forums, part of the PostgreSQL category; --> I found following expression in md.c: seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE))); all variables and constants ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 10:42 AM
Zdenek Kotala
 
Posts: n/a
Default potential integer overflow in md.c

I found following expression in md.c:

seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));

all variables and constants are int (32-bit) and long (also very often
32-bit). In case when somebody want to change RELSEG_SIZE to value
related to 4GB and bigger chunk he can expect data overwriting.

This seek problem is on more places, however in standard compilation
chunk size is 1GB and this problem does not appear.

I'm going to fix it.


Zdenek

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 10:42 AM
Tom Lane
 
Posts: n/a
Default Re: potential integer overflow in md.c

Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:
> I found following expression in md.c:
> seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));


There's no percentage in touching that code unless you intend to enable
the non-segmented behavior; which will probably need more fixes than
just this.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 10:42 AM
Zdenek Kotala
 
Posts: n/a
Default Re: potential integer overflow in md.c

Tom Lane wrote:
> Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:
>> I found following expression in md.c:
>> seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));

>
> There's no percentage in touching that code unless you intend to enable
> the non-segmented behavior; which will probably need more fixes than
> just this.


For non-segment code is following section:

seekpos = (long) (BLCKSZ * (blocknum));

and FileSeek function also accept only 32bit offset.

Zdenek

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:49 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com