Skip to content

Commit 3d0d3c0

Browse files
committed
Cast to (void *) rather than (int *) when passing int64's to PQfn().
This is a possibly-vain effort to silence a Coverity warning about bogus endianness dependency. The code's fine, because it takes care of endianness issues for itself, but Coverity sees an int64 being passed to an int* argument and not unreasonably suspects something's wrong. I'm not sure if putting the void* cast in the way will shut it up; but it can't hurt and seems better from a documentation standpoint anyway, since the pointer is not used as an int* in this code path. Just for a bit of additional safety, verify that the result length is 8 bytes as expected. Back-patch to 9.3 where the code in question was added.
1 parent 089e5ab commit 3d0d3c0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/interfaces/libpq/fe-lobj.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ lo_read(PGconn *conn, int fd, char *buf, size_t len)
290290
argv[1].u.integer = (int) len;
291291

292292
res = PQfn(conn, conn->lobjfuncs->fn_lo_read,
293-
(int *) buf, &result_len, 0, argv, 2);
293+
(void *) buf, &result_len, 0, argv, 2);
294294
if (PQresultStatus(res) == PGRES_COMMAND_OK)
295295
{
296296
PQclear(res);
@@ -441,8 +441,8 @@ lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence)
441441
argv[2].u.integer = whence;
442442

443443
res = PQfn(conn, conn->lobjfuncs->fn_lo_lseek64,
444-
(int *) &retval, &result_len, 0, argv, 3);
445-
if (PQresultStatus(res) == PGRES_COMMAND_OK)
444+
(void *) &retval, &result_len, 0, argv, 3);
445+
if (PQresultStatus(res) == PGRES_COMMAND_OK && result_len == 8)
446446
{
447447
PQclear(res);
448448
return lo_ntoh64(retval);
@@ -607,8 +607,8 @@ lo_tell64(PGconn *conn, int fd)
607607
argv[0].u.integer = fd;
608608

609609
res = PQfn(conn, conn->lobjfuncs->fn_lo_tell64,
610-
(int *) &retval, &result_len, 0, argv, 1);
611-
if (PQresultStatus(res) == PGRES_COMMAND_OK)
610+
(void *) &retval, &result_len, 0, argv, 1);
611+
if (PQresultStatus(res) == PGRES_COMMAND_OK && result_len == 8)
612612
{
613613
PQclear(res);
614614
return lo_ntoh64(retval);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy