diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
new file mode 100644
index 79b59ee..4c08e94
*** a/contrib/pg_upgrade/option.c
--- b/contrib/pg_upgrade/option.c
*************** get_sock_dir(ClusterInfo *cluster, bool
*** 453,461 ****
  					sscanf(line, "%hu", &old_cluster.port);
  				if (lineno == LOCK_FILE_LINE_SOCKET_DIR)
  				{
! 					cluster->sockdir = pg_malloc(MAXPGPATH);
  					/* strip off newline */
! 					sscanf(line, "%s\n", cluster->sockdir);
  				}
  			}
  			fclose(fp);
--- 453,462 ----
  					sscanf(line, "%hu", &old_cluster.port);
  				if (lineno == LOCK_FILE_LINE_SOCKET_DIR)
  				{
! 					cluster->sockdir = pg_strdup(line);
  					/* strip off newline */
! 					if (strchr(cluster->sockdir, '\n') != NULL)
! 						*strchr(cluster->sockdir, '\n') = '\0';
  				}
  			}
  			fclose(fp);
diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c
new file mode 100644
index 71b96bd..1bed8a9
*** a/src/bin/pg_dump/pg_backup_directory.c
--- b/src/bin/pg_dump/pg_backup_directory.c
*************** _LoadBlobs(ArchiveHandle *AH, RestoreOpt
*** 452,457 ****
--- 452,458 ----
  		char		fname[MAXPGPATH];
  		char		path[MAXPGPATH];
  
+ 		/* Can't overflow because line and fname are the same length. */
  		if (sscanf(line, "%u %s\n", &oid, fname) != 2)
  			exit_horribly(modulename, "invalid line in large object TOC file \"%s\": \"%s\"\n",
  						  fname, line);
