Compiler warning about overflow in xlog.c

Started by Petr Jelinekover 10 years ago2 messages
#1Petr Jelinek
petr@2ndquadrant.com
1 attachment(s)

Hi,

my compiler complains about overflow in xlog.c.

There is variable defined as char partialfname[MAXFNAMELEN]; but is used
as snprintf(partialfname, MAXPGPATH, "%s.partial", origfname);

There is no practical issue as the actual filename length is never over
MAXFNAMELEN even with the .partial suffix but the code should still be
fixed which is what attached one-line patch does.

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachments:

xlog-overflow-fix.diffbinary/octet-stream; name=xlog-overflow-fix.diffDownload
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 87a3b48..b913bf3 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7279,7 +7279,7 @@ StartupXLOG(void)
 				char		partialpath[MAXPGPATH];
 
 				XLogFilePath(origpath, EndOfLogTLI, endLogSegNo);
-				snprintf(partialfname, MAXPGPATH, "%s.partial", origfname);
+				snprintf(partialfname, MAXFNAMELEN, "%s.partial", origfname);
 				snprintf(partialpath, MAXPGPATH, "%s.partial", origpath);
 
 				/*
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Petr Jelinek (#1)
Re: Compiler warning about overflow in xlog.c

Petr Jelinek <petr@2ndquadrant.com> writes:

my compiler complains about overflow in xlog.c.

Yeah, Peter E. reported this yesterday. Since Heikki didn't do
anything about that yet, I pushed your fix.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers