Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

+3-2
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

+1
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)