Skip to content

Commit 32be1c8

Browse files
committed
Remove use of sscanf in pg_upgrade, and add C comment to pg_dump
Per report from Jackie Chang
1 parent a0d8947 commit 32be1c8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

contrib/pg_upgrade/option.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,10 @@ get_sock_dir(ClusterInfo *cluster, bool live_check)
453453
sscanf(line, "%hu", &old_cluster.port);
454454
if (lineno == LOCK_FILE_LINE_SOCKET_DIR)
455455
{
456-
cluster->sockdir = pg_malloc(MAXPGPATH);
456+
cluster->sockdir = pg_strdup(line);
457457
/* strip off newline */
458-
sscanf(line, "%s\n", cluster->sockdir);
458+
if (strchr(cluster->sockdir, '\n') != NULL)
459+
*strchr(cluster->sockdir, '\n') = '\0';
459460
}
460461
}
461462
fclose(fp);

src/bin/pg_dump/pg_backup_directory.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
452452
char fname[MAXPGPATH];
453453
char path[MAXPGPATH];
454454

455+
/* Can't overflow because line and fname are the same length. */
455456
if (sscanf(line, "%u %s\n", &oid, fname) != 2)
456457
exit_horribly(modulename, "invalid line in large object TOC file \"%s\": \"%s\"\n",
457458
fname, line);

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