single a suggestion

Started by PostgreSQL Bugs Listabout 25 years ago2 messagesbugs
Jump to latest
#1PostgreSQL Bugs List
pgsql-bugs@postgresql.org

KADIR ROJAS (ridak22@tutopia.com) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
single a suggestion

Long Description
Hello from Panama.

Working with pglib library, I discovered
something, that could become a problem for the developers if they don't
have strict control over what they are doing. It is the PQclear()
function.

When we call this function to release the assigned
resources, and it has been called previously, it is not registered,
causing a segmentation fault in the programs. I think that we could avoid some headaches to our programs, if we give a more robust form to the function,
making a safer PQclear function.

At the time of declaring the pointer to the structure it
must be initialized in NULL (PQresult * res=NULL).
This could guarantee that it won't accidentally release
nonassigned resources. If we make this change the library itself
would be able to have a registry of the calls to the function pqclear,
so, the programmers wouldn't have to worry about this little issue and
concentrate on other subjects. I'd like to know what do you think of this.

thanks a lot for your attention.
KJRC

Sample Code
/* Secure PQclear */
void SPQclear(PQresult **res)
{
if(*res)
{
PQclear(*res);
*res = NULL;
}
return;
}

void main(void)
{
PQresult *res=NULL;

.
.
.
SPQclear(&res);
.
.
.
}

No file was uploaded with this report

#2Piers Scannell
piers.scannell@globecastne.com
In reply to: PostgreSQL Bugs List (#1)
RE: single a suggestion

If the developers don't have strict control over what they are doing - then
I'm confused! Who does have control? Are they using some kind of ghostly
automatic programming whilst in a trance? :-)

Segfaults like that (or failed assertions, etc) are like a big red flag
telling you there's a logic error in your program!

Take things like that away and who knows what little errors slip through
testing and QA ready to bite you after release.

Piers Scannell
Systems Engineer, GlobeCast France Telecom
Tel: +44 1707 667 228 Fax: +44 1707 667 206

Show quoted text

-----Original Message-----
From: pgsql-bugs@postgresql.org [mailto:pgsql-bugs@postgresql.org]
Sent: 06 February 2001 06:12
To: pgsql-bugs@postgresql.org
Subject: [BUGS] single a suggestion

KADIR ROJAS (ridak22@tutopia.com) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
single a suggestion

Long Description
Hello from Panama.

Working with pglib library, I discovered
something, that could become a problem for the developers if
they don't
have strict control over what they are doing. It is the PQclear()
function.

When we call this function to release the assigned
resources, and it has been called previously, it is not registered,
causing a segmentation fault in the programs. I think that we
could avoid some headaches to our programs, if we give a more
robust form to the function,
making a safer PQclear function.

At the time of declaring the pointer to the structure it
must be initialized in NULL (PQresult * res=NULL).
This could guarantee that it won't accidentally release
nonassigned resources. If we make this change the library itself
would be able to have a registry of the calls to the function pqclear,
so, the programmers wouldn't have to worry about this little issue and
concentrate on other subjects. I'd like to know what do you
think of this.

thanks a lot for your attention.
KJRC

Sample Code
/* Secure PQclear */
void SPQclear(PQresult **res)
{
if(*res)
{
PQclear(*res);
*res = NULL;
}
return;
}

void main(void)
{
PQresult *res=NULL;

.
.
.
SPQclear(&res);
.
.
.
}

No file was uploaded with this report