Subject: chmod patch
To: None <tech-userlevel@netbsd.org>
From: Liam J. Foy <liamfoy@sepulcrum.org>
List: tech-userlevel
Date: 05/17/2005 19:36:27
Hey,

	Could you guys look at the following patch:


- setmode(3) can return NULL due to malloc failing. However,
  if malloc does fail an incorrect error message would be 
  printed. You can resolve this by checking errno.

--- chmod.c.old	2005-05-17 19:04:58.000000000 +0100
+++ chmod.c	2005-05-17 19:18:55.000000000 +0100
@@ -149,7 +149,12 @@
 		change_mode = chmod;
 
 	mode = *argv;
+	errno = 0;
 	if ((set = setmode(mode)) == NULL) {
+		if (errno)
+			/* malloc for setmode(3) failed */
+			err(EXIT_FAILURE, "setmode failed");
+
 		errx(EXIT_FAILURE, "invalid file mode: %s", mode);
 		/* NOTREACHED */
 	}

Thanks,
-- 
		- Liam J. Foy
		liamfoy@sepulcrum.org