Fix coverity defects: CID 147587
CID 147587: Out-of-bounds read Future changes may cause an array overrun of 4096 bytes at byte offset 4096 by dereferencing pointer dstp. Adding this additional check ensures correctness. Reviewed-by: Chunwei Chen <david.chen@osnexus.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: GeLiXin <ge.lixin@zte.com.cn> Closes #5297
This commit is contained in:
parent
53ed2db212
commit
547c593661
@ -264,6 +264,13 @@ _zed_event_add_var(uint64_t eid, zed_strings_t *zsp,
|
|||||||
*dstp++ = '=';
|
*dstp++ = '=';
|
||||||
buflen--;
|
buflen--;
|
||||||
|
|
||||||
|
if (buflen <= 0) {
|
||||||
|
errno = EMSGSIZE;
|
||||||
|
zed_log_msg(LOG_WARNING, "Failed to add %s for eid=%llu: %s",
|
||||||
|
keybuf, eid, "Exceeded buffer size");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
va_start(vargs, fmt);
|
va_start(vargs, fmt);
|
||||||
n = vsnprintf(dstp, buflen, fmt, vargs);
|
n = vsnprintf(dstp, buflen, fmt, vargs);
|
||||||
va_end(vargs);
|
va_end(vargs);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user