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.
This commit is contained in:
Ilja van Sprundel 2019-10-11 23:17:40 +02:00 committed by GitHub
parent a8d533d2c9
commit df7dbfe5c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,6 +43,11 @@ int copy_path(char *dest, size_t size)
if (len > M_PATH_STRING_MAX) if (len > M_PATH_STRING_MAX)
return fetch_name(name, len, dest); return fetch_name(name, len, dest);
if (len == 0) {
err_code = EINVAL;
return(EGENERIC);
}
/* Just copy the path from the message */ /* Just copy the path from the message */
strncpy(dest, job_m_in.m_lc_vfs_path.buf, len); strncpy(dest, job_m_in.m_lc_vfs_path.buf, len);