From 846a368fb0b7b4de0940350542bb0af30dd7c5da Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Mon, 5 Mar 2007 23:53:26 +0200 Subject: [PATCH] smb: Assert that there is room for a terminating null. Corresponds to FSP commit 23b4b912ac7486ad969b02bf195ce30ae0eff7f6. --- src/protocol/smb/smb2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/protocol/smb/smb2.c b/src/protocol/smb/smb2.c index 692f8caf..8d58f1f2 100644 --- a/src/protocol/smb/smb2.c +++ b/src/protocol/smb/smb2.c @@ -376,6 +376,15 @@ smb_got_error(struct socket *socket, struct read_buffer *rb) return; } + /* There should be free space in the buffer, because + * @alloc_read_buffer allocated several kibibytes, and the + * child process wrote only an integer and a newline to the + * pipe. */ + assert(rb->freespace >= 1); + if_assert_failed { + abort_connection(conn, S_INTERNAL); + return; + } rb->data[len] = '\0'; error = atoi(rb->data); kill_buffer_data(rb, len);