Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: overflow check in isreallycom



---
 Src/exec.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Src/exec.c b/Src/exec.c
index 95291130ee..98cbb1f609 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1006,13 +1006,15 @@ isreallycom(Cmdnam cn)
     char fullnam[MAXCMDLEN];
 
     if (cn->node.flags & HASHED)
-	strcpy(fullnam, cn->u.cmd);
+	if (snprintf(fullnam, sizeof(fullnam), "%s", cn->u.cmd)
+		>= (int)sizeof(fullnam))
+	    return 0;
     else if (!cn->u.name)
 	return 0;
     else {
-	strcpy(fullnam, *(cn->u.name));
-	strcat(fullnam, "/");
-	strcat(fullnam, cn->node.nam);
+	if (snprintf(fullnam, sizeof(fullnam), "%s/%s",
+		    *(cn->u.name), cn->node.nam) >= (int)sizeof(fullnam))
+	    return 0;
     }
     return iscom(fullnam);
 }
-- 
2.38.1





Messages sorted by: Reverse Date, Date, Thread, Author