pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed From: jackie.qq.chang@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #8540: Avoid sscanf buffer overflow
Date: Sat, 19 Oct 2013 21:49:05 +0000
Message-ID: <E1VXeOP-0002cc-Ow@wrigleys.postgresql.org> (raw )
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 8540
Logged by: Jackie Chang
Email address: jackie.qq.chang@gmail.com
PostgreSQL version: 9.3.1
Operating system: Any
Description:
sscanf can set the maximum length of string read. If such a number is not
provided, it's vulnerable to buffer overflow.
Diff is:
inline patch 1: contrib/pg_upgrade/option.c, src/backend/access/transam/xlog.c (+1/-1 lines) download inline-1.patch diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
index 250aeb8..293ef1c 100644
--- a/contrib/pg_upgrade/option.c
+++ b/contrib/pg_upgrade/option.c
@@ -443,7 +443,7 @@ get_sock_dir(ClusterInfo *cluster, bool live_check)
{
cluster->sockdir = pg_malloc(MAXPGPATH);
/* strip off newline */
- sscanf(line, "%s\n", cluster->sockdir);
+ sscanf(line, "%1023s\n", cluster->sockdir);
}
}
fclose(fp);
diff --git a/src/backend/access/transam/xlog.c
b/src/backend/access/transam/xlog.c
index 06f5eb0..560230f 100644
inline patch 2: src/backend/access/transam/xlog.c (+0/-0 lines) download inline-2.patch --- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -10029,7 +10029,7 @@ do_pg_stop_backup(char *labelfile, bool
waitforarchive, TimeLineID *stoptli_p)
* Read and parse the START WAL LOCATION line (this code is pretty crude,
* but we are not expecting any variability in the file format).
*/
- if (sscanf(labelfile, "START WAL LOCATION: %X/%X (file %24s)%c",
+ if (sscanf(labelfile, "START WAL LOCATION: %X/%X (file %63s)%c",
&hi, &lo, startxlogfilename,
&ch) != 4 || ch != '\n')
ereport(ERROR,
diff --git a/src/bin/pg_dump/pg_backup_directory.c
b/src/bin/pg_dump/pg_backup_directory.c
index f803186..48e0db9 100644
inline patch 3: src/bin/pg_dump/pg_backup_directory.c (+1/-1 lines) download inline-3.patch --- a/src/bin/pg_dump/pg_backup_directory.c
+++ b/src/bin/pg_dump/pg_backup_directory.c
@@ -452,7 +452,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
char fname[MAXPGPATH];
char path[MAXPGPATH];
- if (sscanf(line, "%u %s\n", &oid, fname) != 2)
+ if (sscanf(line, "%u %1023s\n", &oid, fname) != 2)
exit_horribly(modulename, "invalid line in large object TOC file \"%s\":
\"%s\"\n",
fname, line);
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Patches: download all (3 files, .tar.gz)
view thread (2+ messages) latest in thread
Message-ID: <E1VXeOP-0002cc-Ow@wrigleys.postgresql.org>
Permalink: ../E1VXeOP-0002cc-Ow@wrigleys.postgresql.org/
Also on: postgresql.org/message-id/E1VXeOP-0002cc-Ow@wrigleys.postgresql.org
copy link · copy postgr.es · copy git am
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: jackie.qq.chang@gmail.com
Subject: Re: BUG #8540: Avoid sscanf buffer overflow
In-Reply-To: <E1VXeOP-0002cc-Ow@wrigleys.postgresql.org>
References: <E1VXeOP-0002cc-Ow@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox