summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-06-15 05:32:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:17:27 -0500
commit7e40933d7b6f4e32940075bff3a81213d95a59f0 (patch)
treee8dd464a459c527322cff1f440b223eea4ccc9bd /source3
parent8f2d6e4852e13769237f701564f5764361b53603 (diff)
downloadsamba-7e40933d7b6f4e32940075bff3a81213d95a59f0.tar.gz
samba-7e40933d7b6f4e32940075bff3a81213d95a59f0.tar.bz2
samba-7e40933d7b6f4e32940075bff3a81213d95a59f0.zip
r16245: Cope with string being zero len. Klocwork bug #410.
Jeremy. (This used to be commit afe2d4c49333309b940cec8408ccd37ed3747cb7)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/getsmbpass.c6
1 files changed, 4 insertions, 2 deletions
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) {