From 30b16f408c8651cb8d09d812c13a5032d9494447 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Mon, 29 Nov 1999 03:16:29 +0000 Subject: [PATCH] (sec_login): check return value from realloc (sec_end): set app_data to NULL git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7446 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/security.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/appl/ftp/ftp/security.c b/appl/ftp/ftp/security.c index 49a5abef8..e725643c4 100644 --- a/appl/ftp/ftp/security.c +++ b/appl/ftp/ftp/security.c @@ -724,7 +724,15 @@ sec_login(char *host) are usually not very user friendly) */ for(m = mechs; *m && (*m)->name; m++) { - app_data = realloc(app_data, (*m)->size); + void *tmp; + + tmp = realloc(app_data, (*m)->size); + if (tmp == NULL) { + warnx ("realloc %u failed", (*m)->size); + return -1; + } + app_data = tmp; + if((*m)->init && (*(*m)->init)(app_data) != 0) { printf("Skipping %s...\n", (*m)->name); continue; @@ -772,6 +780,7 @@ sec_end(void) (*mech->end)(app_data); memset(app_data, 0, mech->size); free(app_data); + app_data = NULL; } sec_complete = 0; data_prot = (enum protection_level)0;