From 7e40933d7b6f4e32940075bff3a81213d95a59f0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Jun 2006 05:32:21 +0000 Subject: r16245: Cope with string being zero len. Klocwork bug #410. Jeremy. (This used to be commit afe2d4c49333309b940cec8408ccd37ed3747cb7) --- source3/lib/getsmbpass.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/getsmbpass.c b/source3/lib/getsmbpass.c index df5e0359aa..a7780f7c12 100644 --- a/source3/lib/getsmbpass.c +++ b/source3/lib/getsmbpass.c @@ -147,8 +147,10 @@ char *getsmbpass(const char *prompt) fgets(buf, bufsize, in); } nread = strlen(buf); - if (buf[nread - 1] == '\n') - buf[nread - 1] = '\0'; + if (nread) { + if (buf[nread - 1] == '\n') + buf[nread - 1] = '\0'; + } /* Restore echoing. */ if (echo_off) { -- cgit