(sec_end): only clean app_data if there is any
(*): do realloc consistently git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9654 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998-2000 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1998-2001 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -166,6 +166,7 @@ sec_get_data(int fd, struct buffer *buf, int level)
|
|||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int b;
|
int b;
|
||||||
|
void *tmp;
|
||||||
|
|
||||||
b = block_read(fd, &len, sizeof(len));
|
b = block_read(fd, &len, sizeof(len));
|
||||||
if (b == 0)
|
if (b == 0)
|
||||||
@@ -173,7 +174,10 @@ sec_get_data(int fd, struct buffer *buf, int level)
|
|||||||
else if (b < 0)
|
else if (b < 0)
|
||||||
return -1;
|
return -1;
|
||||||
len = ntohl(len);
|
len = ntohl(len);
|
||||||
buf->data = realloc(buf->data, len);
|
tmp = realloc(buf->data, len);
|
||||||
|
if (tmp == NULL)
|
||||||
|
return -1;
|
||||||
|
buf->data = tmp;
|
||||||
b = block_read(fd, buf->data, len);
|
b = block_read(fd, buf->data, len);
|
||||||
if (b == 0)
|
if (b == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -424,9 +428,17 @@ void
|
|||||||
auth(char *auth_name)
|
auth(char *auth_name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
void *tmp;
|
||||||
|
|
||||||
for(i = 0; (mech = mechs[i]) != NULL; i++){
|
for(i = 0; (mech = mechs[i]) != NULL; i++){
|
||||||
if(!strcasecmp(auth_name, mech->name)){
|
if(!strcasecmp(auth_name, mech->name)){
|
||||||
app_data = realloc(app_data, mech->size);
|
tmp = realloc(app_data, mech->size);
|
||||||
|
if (tmp == NULL) {
|
||||||
|
reply(431, "Unable to accept %s at this time", mech->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
app_data = tmp;
|
||||||
|
|
||||||
if(mech->init && (*mech->init)(app_data) != 0) {
|
if(mech->init && (*mech->init)(app_data) != 0) {
|
||||||
reply(431, "Unable to accept %s at this time", mech->name);
|
reply(431, "Unable to accept %s at this time", mech->name);
|
||||||
return;
|
return;
|
||||||
@@ -443,6 +455,7 @@ auth(char *auth_name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free (app_data);
|
free (app_data);
|
||||||
|
app_data = NULL;
|
||||||
reply(504, "%s is unknown to me", auth_name);
|
reply(504, "%s is unknown to me", auth_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -776,9 +789,11 @@ sec_end(void)
|
|||||||
if (mech != NULL) {
|
if (mech != NULL) {
|
||||||
if(mech->end)
|
if(mech->end)
|
||||||
(*mech->end)(app_data);
|
(*mech->end)(app_data);
|
||||||
memset(app_data, 0, mech->size);
|
if (app_data != NULL) {
|
||||||
free(app_data);
|
memset(app_data, 0, mech->size);
|
||||||
app_data = NULL;
|
free(app_data);
|
||||||
|
app_data = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sec_complete = 0;
|
sec_complete = 0;
|
||||||
data_prot = (enum protection_level)0;
|
data_prot = (enum protection_level)0;
|
||||||
|
Reference in New Issue
Block a user