aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2025-04-03 19:01:02 +0200
committerStefano Brivio <sbrivio@redhat.com>2025-04-05 11:28:23 +0200
commit06784d7fc6761528d587837b241d27c6d17c0842 (patch)
treea0122a9cdba409798600e0fdd509bcb88afb395d
parent684870a766e7f024a5720464ad070e666cb4793e (diff)
downloadpasst-06784d7fc6761528d587837b241d27c6d17c0842.tar
passt-06784d7fc6761528d587837b241d27c6d17c0842.tar.gz
passt-06784d7fc6761528d587837b241d27c6d17c0842.tar.bz2
passt-06784d7fc6761528d587837b241d27c6d17c0842.tar.lz
passt-06784d7fc6761528d587837b241d27c6d17c0842.tar.xz
passt-06784d7fc6761528d587837b241d27c6d17c0842.tar.zst
passt-06784d7fc6761528d587837b241d27c6d17c0842.zip
passt-repair: Ensure that read buffer is NULL-terminated
After 3d41e4d83895 ("passt-repair: Correct off-by-one error verifying name"), Coverity Scan isn't convinced anymore about the fact that the ev->name used in the snprintf() is NULL-terminated. It comes from a read() call, and read() of course doesn't terminate it, but we already check that the byte at ev->len - 1 is a NULL terminator, so this is actually a false positive. In any case, the logic ensuring that ev->name is NULL-terminated isn't necessarily obvious, and additionally checking that the last byte in the buffer we read is a NULL terminator is harmless, so do that explicitly, even if it's redundant. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--passt-repair.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/passt-repair.c b/passt-repair.c
index 440c77a..256a8c9 100644
--- a/passt-repair.c
+++ b/passt-repair.c
@@ -137,6 +137,7 @@ int main(int argc, char **argv)
fprintf(stderr, "inotify read: %i", errno);
_exit(1);
}
+ buf[n - 1] = '\0';
if (n < (ssize_t)sizeof(*ev)) {
fprintf(stderr, "Short inotify read: %zi", n);