From 3c3da1958e8c33cd8023a17ca972e9baec02d025 Mon Sep 17 00:00:00 2001 From: "Liam J. Foy" Date: Sun, 28 Nov 2004 21:17:07 +0000 Subject: [PATCH] - Fix setmode. Setmode can fail due to malloc. We should print the correct error message if malloc does fail and not print incorrect file mode. --- usr.bin/find/function.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 468ba7c99e..d75dd05960 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -35,7 +35,7 @@ * * @(#)function.c 8.10 (Berkeley) 5/4/95 * $FreeBSD: src/usr.bin/find/function.c,v 1.22.2.11 2002/11/15 11:38:15 sheldonh Exp $ - * $DragonFly: src/usr.bin/find/function.c,v 1.3 2003/10/04 20:36:44 hmp Exp $ + * $DragonFly: src/usr.bin/find/function.c,v 1.4 2004/11/28 21:17:07 liamfoy Exp $ */ #include @@ -1038,8 +1038,13 @@ c_perm(OPTION *option, char ***argvp) ++perm; } - if ((set = setmode(perm)) == NULL) - errx(1, "%s: %s: illegal mode string", option->name, perm); + errno = 0; + if ((set = setmode(perm)) == NULL) { + if (!errno) + errx(1, "%s: %s: illegal mode string", option->name, perm); + else + err(1, "malloc failed"); + } new->m_data = getmode(set, 0); free(set); -- 2.32.0