aboutsummaryrefslogtreecommitdiff
path: root/libssh/keyfiles.c
diff options
context:
space:
mode:
authorDmitry V. Krivenok <krivenok@orangesystem.ru>2009-09-10 16:08:41 +0400
committerAndreas Schneider <mail@cynapses.org>2009-09-10 14:35:02 +0200
commit18bce136178029b52cbc7097d85cc0e50da887d8 (patch)
tree880b55e0e0e1ecfccb068459f81a21eb87c4a2e9 /libssh/keyfiles.c
parent2a10019f82b9db58d7821ef93febc42b54042c92 (diff)
downloadlibssh-18bce136178029b52cbc7097d85cc0e50da887d8.tar.gz
libssh-18bce136178029b52cbc7097d85cc0e50da887d8.tar.xz
libssh-18bce136178029b52cbc7097d85cc0e50da887d8.zip
Fixed possible memory leak in lowercase function.
If user passed NULL pointer to lowercase() function, duplicated string "new" wasn't freed before return. Signed-off-by: Dmitry V. Krivenok <krivenok@orangesystem.ru> Signed-off-by: Andreas Schneider <mail@cynapses.org>
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r--libssh/keyfiles.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c
index 0e73fcba..f21cbe1f 100644
--- a/libssh/keyfiles.c
+++ b/libssh/keyfiles.c
@@ -1019,11 +1019,12 @@ static int alldigits(const char *s) {
*/
static char *lowercase(const char* str) {
char *p = 0;
- char *new = strdup(str);
+ char *new = NULL;
- if((str == NULL) || (new == NULL)) {
- return NULL;
- }
+ if(str == NULL) return NULL;
+
+ new = strdup(str);
+ if(new == NULL) return NULL;
for (p = new; *p; p++) {
*p = tolower(*p);