Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 213453 - dev-db/pgeasy - Incorrect memory handling
Summary: dev-db/pgeasy - Incorrect memory handling
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: High normal
Assignee: PgSQL Bugs
URL: http://www.msl37.org/
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-14 23:23 UTC by Ricardo I. Vieitez
Modified: 2008-06-04 21:59 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch that should fix the incorrect handling (libpgeasy.c.diff,1.74 KB, patch)
2008-03-14 23:25 UTC, Ricardo I. Vieitez
Details | Diff
Patch that fixes the BUG in a Linux-based system. Apparently unnecessary in BSD systems. (libpgeasy.c.diff,1.66 KB, patch)
2008-03-15 13:32 UTC, Ricardo I. Vieitez
Details | Diff
Program that shows the problem. (memcpy_t.c,956 bytes, text/plain)
2008-03-15 13:36 UTC, Ricardo I. Vieitez
Details
This patched header just adds C++ compatibility (libpgeasy.h.diff,429 bytes, patch)
2008-03-15 13:36 UTC, Ricardo I. Vieitez
Details | Diff
Fixes the BUG, AND is cross-platform, (libpgeasy.c.diff,2.45 KB, patch)
2008-03-15 16:49 UTC, Ricardo I. Vieitez
Details | Diff
Program that shows the problem and shows the proper way for the system (memcpy or memrev) (memcpy_t.c,3.24 KB, text/plain)
2008-03-15 16:56 UTC, Ricardo I. Vieitez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ricardo I. Vieitez 2008-03-14 23:23:49 UTC
This library, libpgeasy (ebuild alias dev-libs/libpgeasy) has an incorrect memory handling when getting raw values from PostgreSQL server, providing the values multiplied by 256^(field size in Bytes - 1).
The bug is ocurring because it gets data (for example, for value 1) in this way from server: 0x0 0x0 0x0 0x1, and then uses it as it was given when the order has to be inverted to be usable.
In particular, all the anormality is caused for calling memcpy() in functions fetch() and fetchwithnulls().
I'll attach a patch at the end of this message.
Comment 1 Ricardo I. Vieitez 2008-03-14 23:25:07 UTC
Created attachment 146173 [details, diff]
Patch that should fix the incorrect handling
Comment 2 Ricardo I. Vieitez 2008-03-14 23:27:54 UTC
(In reply to comment #1)
> Created an attachment (id=146173) [edit]
> Patch that should fix the incorrect handling
> 

ebuild name is not dev-libs/libpgeasy but dev-db/pgeasy.
Comment 3 Ricardo I. Vieitez 2008-03-15 13:32:49 UTC
Created attachment 146216 [details, diff]
Patch that fixes the BUG in a Linux-based system.
Apparently unnecessary in  BSD systems. 

The old attachment inverted strings, copying, i.e., ANITNEGRA instead of ARGENTINA.
Comment 4 Ricardo I. Vieitez 2008-03-15 13:36:03 UTC
Created attachment 146217 [details]
Program that shows the problem.

This simple program in C shows how the order of the bytes affected the result.
Comment 5 Ricardo I. Vieitez 2008-03-15 13:36:59 UTC
Created attachment 146218 [details, diff]
This patched header just adds C++ compatibility
Comment 6 Jakub Moc (RETIRED) gentoo-dev 2008-03-15 13:56:50 UTC
(In reply to comment #3)
> The old attachment inverted strings, copying, i.e., ANITNEGRA instead of
> ARGENTINA.

LOLZ.... 

Comment 7 Ricardo I. Vieitez 2008-03-15 14:25:41 UTC
The provided patch applies for Linux only.
In BSD, the original code would work properly, as it was tested with the memcpy_t.c attachment.
Comment 8 Ricardo I. Vieitez 2008-03-15 16:49:34 UTC
Created attachment 146236 [details, diff]
Fixes the BUG, AND is cross-platform,
Comment 9 Ricardo I. Vieitez 2008-03-15 16:56:25 UTC
Created attachment 146238 [details]
Program that shows the problem and shows the proper way for the system (memcpy or memrev)

This program implements a function to detect if it is needed or not to reverse the bytes order.
Comment 10 Tiziano Müller (RETIRED) gentoo-dev 2008-06-04 21:59:30 UTC
I'm sorry. But pgeasy seems to be dead. I've therefore masked it for removal. And I therefore won't fix this.