vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Jan F. Chadima f4b0b4
diff -up openssh-5.2p1/ssh.c.pathmax openssh-5.2p1/ssh.c
Jan F. Chadima 3d6b00
--- openssh-5.2p1/ssh.c.pathmax	2009-07-08 14:23:19.000000000 +0200
Jan F. Chadima 3d6b00
+++ openssh-5.2p1/ssh.c	2009-07-08 14:26:26.000000000 +0200
Jan F. Chadima f4b0b4
@@ -49,6 +49,7 @@
Jan F. Chadima f4b0b4
 #include <sys/resource.h>
Jan F. Chadima f4b0b4
 #include <sys/ioctl.h>
Jan F. Chadima f4b0b4
 #include <sys/socket.h>
Jan F. Chadima f4b0b4
+#include <sys/param.h>
Jan F. Chadima f4b0b4
 
Jan F. Chadima f4b0b4
 #include <ctype.h>
Jan F. Chadima f4b0b4
 #include <errno.h>
Jan F. Chadima 3d6b00
@@ -208,8 +209,8 @@ void muxserver_listen(void);
Jan F. Chadima 3d6b00
 int
Jan F. Chadima f4b0b4
 main(int ac, char **av)
Jan F. Chadima f4b0b4
 {
Jan F. Chadima 3d6b00
-	int i, opt, exit_status, use_syslog;
Jan F. Chadima f4b0b4
-	char *p, *cp, *line, buf[256];
Jan F. Chadima 3d6b00
+	int i, r, opt, exit_status, use_syslog;
Jan F. Chadima 3d6b00
+	char *p, *cp, *line, buf[MAXPATHLEN];
Jan F. Chadima f4b0b4
 	struct stat st;
Jan F. Chadima f4b0b4
 	struct passwd *pw;
Jan F. Chadima f4b0b4
 	int dummy, timeout_ms;
Jan F. Chadima 3d6b00
@@ -624,9 +625,10 @@ main(int ac, char **av)
Jan F. Chadima 3d6b00
 			fatal("Can't open user config file %.100s: "
Jan F. Chadima 3d6b00
 			    "%.100s", config, strerror(errno));
Jan F. Chadima 3d6b00
 	} else {
Jan F. Chadima 3d6b00
-		snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir,
Jan F. Chadima 3d6b00
+		r = snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir,
Jan F. Chadima 3d6b00
 		    _PATH_SSH_USER_CONFFILE);
Jan F. Chadima 3d6b00
-		(void)read_config_file(buf, host, &options, 1);
Jan F. Chadima 3d6b00
+		if (r > 0 && (size_t)r < sizeof(buf))
Jan F. Chadima 3d6b00
+			(void)read_config_file(buf, host, &options, 1);
Jan F. Chadima 3d6b00
 
Jan F. Chadima 3d6b00
 		/* Read systemwide configuration file after use config. */
Jan F. Chadima 3d6b00
 		(void)read_config_file(_PATH_HOST_CONFIG_FILE, host,
Jan F. Chadima 3d6b00
@@ -787,9 +789,9 @@ main(int ac, char **av)
Jan F. Chadima 3d6b00
 	 * Now that we are back to our own permissions, create ~/.ssh
Jan F. Chadima 3d6b00
 	 * directory if it doesn't already exist.
Jan F. Chadima 3d6b00
 	 */
Jan F. Chadima 3d6b00
-	snprintf(buf, sizeof buf, "%.100s%s%.100s", pw->pw_dir,
Jan F. Chadima 3d6b00
+	r = snprintf(buf, sizeof buf, "%s%s%s", pw->pw_dir,
Jan F. Chadima 3d6b00
 	    strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR);
Jan F. Chadima 3d6b00
-	if (stat(buf, &st) < 0)
Jan F. Chadima 3d6b00
+	if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0)
Jan F. Chadima 3d6b00
 		if (mkdir(buf, 0700) < 0)
Jan F. Chadima 3d6b00
 			error("Could not create directory '%.200s'.", buf);
Jan F. Chadima 3d6b00