shithub: fingerd

Download patch

ref: 23aaf92ee4cc8844a5390e3048a23b39c917730c
parent: a650163aca0079b9166adadf0360967d8d152060
author: sirjofri <[email protected]>
date: Thu Apr 15 04:05:35 EDT 2021

fixes edge cases and error message output

--- a/fingerd.c
+++ b/fingerd.c
@@ -46,8 +46,8 @@
 splitpath(char *req)
 {
 	char *file;
-	file = strrchr(req, '/');
-	if (file == nil || strlen(file) == 0)
+	file = strchr(req, '/');
+	if (file == nil || strlen(file) <= 1)
 		return "finger";
 	file[0] = 0;
 	return file+1;
@@ -129,6 +129,10 @@
 	default: /* user request   */
 		file = splitpath(req);
 		user = req;
+		if (strlen(user) <= 0) {
+			print("bad request.\n");
+			break;
+		}
 		path = smprint("/usr/%s/finger/finger", user);
 		if (!vaccess(path)){
 			printnouser(user);
@@ -137,7 +141,7 @@
 		free(path);
 		path = smprint("/usr/%s/finger/%s", user, file);
 		if (!cat(path, OREAD))
-			printnofile(path);
+			printnofile(file);
 		free(path);
 	}
 }