Commit 9688b688 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix memory leaks in error-handling paths in configuration parser.

parent 4d8a8315
...@@ -1214,23 +1214,28 @@ parse_config_line(int c, gnc_t gnc, void *closure, ...@@ -1214,23 +1214,28 @@ parse_config_line(int c, gnc_t gnc, void *closure,
struct key *key = NULL; struct key *key = NULL;
c = parse_key(c, gnc, closure, &key); c = parse_key(c, gnc, closure, &key);
if(c < -1 || key == NULL || key->id == NULL) { if(c < -1 || key == NULL || key->id == NULL) {
if(key != NULL)
free(key->value);
free(key); free(key);
goto fail; goto fail;
} }
switch(key->type) { switch(key->type) {
case AUTH_TYPE_SHA256: case AUTH_TYPE_SHA256:
if(key->len != 32) { if(key->len != 32) {
free(key->value);
free(key); free(key);
goto fail; goto fail;
} }
break; break;
case AUTH_TYPE_BLAKE2S: case AUTH_TYPE_BLAKE2S:
if(key->len != 16) { if(key->len != 16) {
free(key->value);
free(key); free(key);
goto fail; goto fail;
} }
break; break;
default: default:
free(key->value);
free(key); free(key);
goto fail; goto fail;
} }
......
...@@ -24,6 +24,7 @@ THE SOFTWARE. ...@@ -24,6 +24,7 @@ THE SOFTWARE.
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <sys/time.h>
#include <netinet/in.h> #include <netinet/in.h>
#include "rfc6234/sha.h" #include "rfc6234/sha.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment