summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-06-15 05:32:21 +0000
committerStefan Metzmacher <metze@samba.org>2007-10-15 13:20:40 +0200
commit335c35318a698631bf1db068e110d66b14f0b2d6 (patch)
tree1727528d2c3928f66a2ffe0ee697d948fde6bad5 /source3
parent3c258755b52026e868fe9b6fa5f7291023007f8f (diff)
downloadsamba-335c35318a698631bf1db068e110d66b14f0b2d6.tar.gz
samba-335c35318a698631bf1db068e110d66b14f0b2d6.tar.bz2
samba-335c35318a698631bf1db068e110d66b14f0b2d6.zip
r16245: Cope with string being zero len. Klocwork bug #410. Jeremy.
(This used to be commit 46c12de07fe6f44bcf58ca9de276e7932384843d)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/replace/getpass.c6
1 files 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) {