From: deraadt Date: Wed, 15 Dec 2021 04:01:52 +0000 (+0000) Subject: getcwd() operates on buffers of PATH_MAX including the NUL, and the +1 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=993f8b84c9ce4be4421cebb4b89dce2fe71fa7b0;p=openbsd 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 --- 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;