From 335c35318a698631bf1db068e110d66b14f0b2d6 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 46c12de07fe6f44bcf58ca9de276e7932384843d) --- source3/lib/replace/getpass.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source3/lib/replace/getpass.c b/source3/lib/replace/getpass.c index 96f508ead2..c67ff2bda7 100644 --- a/source3/lib/replace/getpass.c +++ b/source3/lib/replace/getpass.c @@ -202,8 +202,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