summaryrefslogtreecommitdiff
path: root/source3/utils/smbget.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-11-30 21:48:33 +0100
committerVolker Lendecke <vl@samba.org>2009-11-30 21:48:59 +0100
commit6aef5e591f3fa1ceeedb22273d2fe04298b6e3fb (patch)
tree71eed40f3bdddd8085f57ef5ae581ee03bc0c30e /source3/utils/smbget.c
parent3b7f8a759f57f32a8c1bc2db85236e88f616ffd9 (diff)
downloadsamba-6aef5e591f3fa1ceeedb22273d2fe04298b6e3fb.tar.gz
samba-6aef5e591f3fa1ceeedb22273d2fe04298b6e3fb.tar.bz2
samba-6aef5e591f3fa1ceeedb22273d2fe04298b6e3fb.zip
Fix bug 6546: Avoid accessing buf[-1] if NUL byte comes from fgets
Diffstat (limited to 'source3/utils/smbget.c')
-rw-r--r--source3/utils/smbget.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index b7d56cdcba..15fe1fd70a 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -94,7 +94,9 @@ static void get_auth_data(const char *srv, const char *shr, char *wg, int wglen,
if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
return;
}
- if(tmp[strlen(tmp)-1] == '\n')tmp[strlen(tmp)-1] = '\0';
+ if ((strlen(tmp) > 0) && (tmp[strlen(tmp)-1] == '\n')) {
+ tmp[strlen(tmp)-1] = '\0';
+ }
strncpy(un, tmp, unlen-1);
} else if(username) strncpy(un, username, unlen-1);