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:
parent
a8d533d2c9
commit
df7dbfe5c6
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user