From a00fe6b7fd2c87394f0b8ffc1b37f9428eb4a824 Mon Sep 17 00:00:00 2001 From: Johnothan King Date: Wed, 9 Feb 2022 18:04:44 -0800 Subject: [PATCH] Fix one buffer overflow in 'typeset -p .sh.type' (#457) This small commit replaces one instance of memcmp with strncmp to fix one of the buffer overflows that causes 'typeset -p .sh.type' to crash (see also https://github.com/ksh93/ksh/issues/456). --- src/cmd/ksh93/sh/nvtype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/ksh93/sh/nvtype.c b/src/cmd/ksh93/sh/nvtype.c index 0a5c0693d..b8c6aaece 100644 --- a/src/cmd/ksh93/sh/nvtype.c +++ b/src/cmd/ksh93/sh/nvtype.c @@ -1473,7 +1473,7 @@ int sh_outtype(Sfio_t *out) { if(nv_isnull(tp) || !nv_isvtree(tp)) continue; - if(indent && (memcmp(tp->nvname,sh.prefix,n-1) || tp->nvname[n-1]!='.' || strchr(tp->nvname+n,'.'))) + if(indent && (strncmp(tp->nvname,sh.prefix,n-1) || tp->nvname[n-1]!='.' || strchr(tp->nvname+n,'.'))) continue; nv_settype(L_ARGNOD,tp,0); if(indent)