From db9180c3d91253ee7dac1ed943f9a5a5b9e1a5a7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 20 Jun 2012 10:26:58 +0200 Subject: idmap-hash: Attempt to fix Coverity ID 709116 Overflowed array index write Signed-off-by: Michael Adam Autobuild-User(master): Michael Adam Autobuild-Date(master): Wed Jun 20 12:53:59 CEST 2012 on sn-devel-104 --- source3/winbindd/idmap_hash/mapfile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source3/winbindd/idmap_hash/mapfile.c b/source3/winbindd/idmap_hash/mapfile.c index ec846f37eb..a0e2b489cb 100644 --- a/source3/winbindd/idmap_hash/mapfile.c +++ b/source3/winbindd/idmap_hash/mapfile.c @@ -74,7 +74,12 @@ static bool mapfile_read_line(fstring key, fstring value) /* Strip newlines and carriage returns */ - len = strlen_m(buffer) - 1; + len = strlen_m(buffer); + if (len == 0) { + return false; + } + len -= 1; + while ((buffer[len] == '\n') || (buffer[len] == '\r')) { buffer[len--] = '\0'; } -- cgit