From 993f8b84c9ce4be4421cebb4b89dce2fe71fa7b0 Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 15 Dec 2021 04:01:52 +0000 Subject: [PATCH] getcwd() operates on buffers of PATH_MAX including the NUL, and the +1 is not unneccesary. Different buffer sizes are actually dangerous, though major problems are strangely rare. ok millert --- bin/ksh/misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ksh/misc.c b/bin/ksh/misc.c index 672b5416419..3d1e0cd4afb 100644 --- a/bin/ksh/misc.c +++ b/bin/ksh/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.76 2020/10/26 18:16:51 tb Exp $ */ +/* $OpenBSD: misc.c,v 1.77 2021/12/15 04:01:52 deraadt Exp $ */ /* * Miscellaneous functions @@ -1135,7 +1135,7 @@ ksh_get_wd(char *buf, int bsize) /* Assume getcwd() available */ if (!buf) { bsize = PATH_MAX; - b = alloc(PATH_MAX + 1, ATEMP); + b = alloc(bsize, ATEMP); } else b = buf; -- 2.20.1