Commit Diff


commit - e89c5ddbae4d5fd7e9d51feb3e66e4903c0b12301a3868e780be8c4e2d745a9e
commit + ec26929e015920fa60766b5fcd9baa504368d0dcd68e9f0c42c3c9bba9e5faff
blob - 79a17abde6b9199445d4e4b75920548b1e607cfba97db663e79ab52a5741cd7d
blob + eb820eaad044f0c4445585497cd57df690853712820086932d419699dbbbec16
--- gotd/parse.y	
+++ gotd/parse.y	
@@ -675,13 +675,15 @@ repository	: REPOSITORY STRING {
 repoopts1	: PATH STRING {
 			if (gotd_proc_id == GOTD_PROC_GOTD ||
 			    gotd_proc_id == GOTD_PROC_GITWRAPPER) {
+				char *repo_path;
 				if (!got_path_is_absolute($2)) {
 					yyerror("%s: path %s is not absolute",
 					    __func__, $2);
 					free($2);
 					YYERROR;
 				}
-				if (realpath($2, new_repo->path) == NULL) {
+				repo_path = realpath($2, NULL);
+				if (repo_path == NULL) {
 					/*
 					 * To give admins a chance to create
 					 * missing repositories at run-time
@@ -707,8 +709,19 @@ repoopts1	: PATH STRING {
 					    sizeof(new_repo->path)) >=
 					    sizeof(new_repo->path)) {
 						yyerror("path too long");
+						free($2);
 						YYERROR;
 					}
+				} else {
+					if (strlcpy(new_repo->path, repo_path,
+					    sizeof(new_repo->path)) >=
+					    sizeof(new_repo->path)) {
+						yyerror("path too long");
+						free(repo_path);
+						free($2);
+						YYERROR;
+					}
+					free(repo_path);
 				}
 			}
 			free($2);
blob - 676e58a60c88b9443fb7398e03ea50e470addb8917834717bada46d865b16116
blob + efd061a7a9f7112cf5445628c0603774ca2fc0b4191329fb12f59c668de9171c
--- gotsysd/libexec/gotsys-repo-create/gotsys-repo-create.c	
+++ gotsysd/libexec/gotsys-repo-create/gotsys-repo-create.c	
@@ -387,7 +387,7 @@ main(int argc, char **argv)
 	struct gotsysd_imsgev iev;
 	struct event evsigint, evsigterm, evsighup, evsigusr1;
 	struct passwd *pw;
-	char *username;
+	char *username, *p;
 	struct stat sb;
 #if 0
 	static int attached;
@@ -409,8 +409,12 @@ main(int argc, char **argv)
 		errx(1, "usage: %s username repos_path", getprogname());
 
 	username = argv[1];
-	if (realpath(argv[2], repos_path) == NULL)
+	p = realpath(argv[2], NULL);
+	if (p == NULL)
 		err(1, "realpath %s", argv[2]);
+	if (strlcpy(repos_path, p, sizeof(repos_path)) >= sizeof(repos_path))
+		err(1, "path too long: %s", p);
+	free(p);
 
 	pw = getpwnam(username);
 	if (pw == NULL)
blob - 453889c58d0fd6e1bb5f5a1cf57a9ba88e969570a7350ca6a19da1322e0a0b44
blob + 875a2c79968bea7ccc9c774dcdc81498c153ba6ad12a469832cfc5fb0fbc381a
--- gotsysd/parse.y	
+++ gotsysd/parse.y	
@@ -191,11 +191,14 @@ listen_addr	: '*' { $$ = NULL; }
 		;
 
 main		: LISTEN ON STRING {
+			char *p;
+
 			if (!got_path_is_absolute($3))
 				yyerror("bad unix socket path \"%s\": "
 				    "must be an absolute path", $3);
 
-			if (realpath($3, gotsysd->unix_socket_path) == NULL) {
+			p = realpath($3, NULL);
+			if (p == NULL) {
 				if (errno != ENOENT && errno != EACCES) {
 					yyerror("realpath %s: %s", $3,
 					    strerror(errno));
@@ -211,6 +214,17 @@ main		: LISTEN ON STRING {
 					free($3);
 					YYERROR;
 				}
+			} else {
+				if (strlcpy(gotsysd->unix_socket_path, p,
+				    sizeof(gotsysd->unix_socket_path)) >=
+				    sizeof(gotsysd->unix_socket_path)) {
+					yyerror("unix socket path too long: %s",
+					    p);
+					free(p);
+					free($3);
+					YYERROR;
+				}
+				free(p);
 			}
 			free($3);
 		}
@@ -235,6 +249,8 @@ main		: LISTEN ON STRING {
 			free($3);
 		}
 		| REPOSITORY DIRECTORY STRING {
+			char *p;
+
 			if (!got_path_is_absolute($3)) {
 				yyerror("bad path \"%s\": "
 				    "must be an absolute path", $3);
@@ -242,11 +258,20 @@ main		: LISTEN ON STRING {
 				YYERROR;
 			}
 
-			if (realpath($3, gotsysd->repos_path) == NULL) {
+			p = realpath($3, NULL);
+			if (p == NULL) {
 				yyerror("realpath %s: %s", $3, strerror(errno));
 				free($3);
 				YYERROR;
 			}
+			if (strlcpy(gotsysd->repos_path, p,
+			    sizeof(gotsysd->repos_path)) >=
+			    sizeof(gotsysd->repos_path)) {
+				yyerror("repository path too long: %s", p);
+				free(p);
+				free($3);
+				YYERROR;
+			}
 			free($3);
 		}
 		| UID RANGE NUMBER NUMBER {