summaryrefslogtreecommitdiff
path: root/source4/lib/replace
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-10-17 14:00:57 +0200
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:43:11 +0100
commit066f56bfeffcbd4808606d4a81c0f0cefa92e07e (patch)
tree5f04b973da1285ebc74180db83658d59caa13144 /source4/lib/replace
parent50a749404bb1d86f0881fab06414469fda307c26 (diff)
downloadsamba-066f56bfeffcbd4808606d4a81c0f0cefa92e07e.tar.gz
samba-066f56bfeffcbd4808606d4a81c0f0cefa92e07e.tar.bz2
samba-066f56bfeffcbd4808606d4a81c0f0cefa92e07e.zip
r25681: r16245: Cope with string being zero len. Klocwork bug #410. Jeremy.
(cherry picked from commit 46c12de07fe6f44bcf58ca9de276e7932384843d) (This used to be commit 7099dde3fd8962e752451ebe2d5d79de4d7caee9)
Diffstat (limited to 'source4/lib/replace')
-rw-r--r--source4/lib/replace/getpass.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c
index 96f508ead2..c67ff2bda7 100644
--- a/source4/lib/replace/getpass.c
+++ b/source4/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) {