hdb: don't use lock_file name after free in open_lock_file
This commit is contained in:

committed by
Nico Williams

parent
efba1c21e9
commit
59d132f825
@@ -136,6 +136,7 @@ static krb5_error_code
|
|||||||
open_lock_file(krb5_context context, const char *db_name, int *fd)
|
open_lock_file(krb5_context context, const char *db_name, int *fd)
|
||||||
{
|
{
|
||||||
char *lock_file;
|
char *lock_file;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
/* lock old and new databases */
|
/* lock old and new databases */
|
||||||
asprintf(&lock_file, "%s.lock", db_name);
|
asprintf(&lock_file, "%s.lock", db_name);
|
||||||
@@ -145,14 +146,13 @@ open_lock_file(krb5_context context, const char *db_name, int *fd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*fd = open(lock_file, O_RDWR | O_CREAT, 0600);
|
*fd = open(lock_file, O_RDWR | O_CREAT, 0600);
|
||||||
free(lock_file);
|
|
||||||
if(*fd < 0) {
|
if(*fd < 0) {
|
||||||
int ret = errno;
|
ret = errno;
|
||||||
krb5_set_error_message(context, ret, "open(%s): %s", lock_file,
|
krb5_set_error_message(context, ret, "open(%s): %s", lock_file,
|
||||||
strerror(ret));
|
strerror(ret));
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
return 0;
|
free(lock_file);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user