From df7dbfe5c608e7ea1cfc747172605611305a119b Mon Sep 17 00:00:00 2001 From: Ilja van Sprundel Date: Fri, 11 Oct 2019 23:17:40 +0200 Subject: [PATCH] make sure len is not 0 This change makes sure len is not 0. If len is 0 an int underflow would occur when looking for a terminating 0-byte and could lead to operating on uninitialized data. --- minix/servers/vfs/utility.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/minix/servers/vfs/utility.c b/minix/servers/vfs/utility.c index f68bf38be..85763d33e 100644 --- a/minix/servers/vfs/utility.c +++ b/minix/servers/vfs/utility.c @@ -43,6 +43,11 @@ int copy_path(char *dest, size_t size) if (len > M_PATH_STRING_MAX) return fetch_name(name, len, dest); + if (len == 0) { + err_code = EINVAL; + return(EGENERIC); + } + /* Just copy the path from the message */ strncpy(dest, job_m_in.m_lc_vfs_path.buf, len);