From 3313fc410be0ffabae019de644f041064b054142 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Wed, 22 Sep 2021 22:43:18 +0200 Subject: record/zonefile: malloc checks --- src/record.c | 4 +++- src/zonefile.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/record.c b/src/record.c index e323718..e6e70dc 100644 --- a/src/record.c +++ b/src/record.c @@ -155,11 +155,13 @@ static ssize_t record_rdata_a(char* _str, void** _rdata) { len = strlen(_str) + 1; str = malloc(len); + if ( !str ) + return -1; strncpy(str, _str, len); *_rdata = malloc(4); if ( !*_rdata ) - return -1; + goto err; tok = strtok(str, "."); if( !tok ) diff --git a/src/zonefile.c b/src/zonefile.c index 1b0d036..1701ff8 100644 --- a/src/zonefile.c +++ b/src/zonefile.c @@ -52,6 +52,10 @@ int zonefile_parse_line(database_t *_database, char *_line) { return -1; } qname = malloc( (unsigned)fqdn_len+2 ); + if( !qname ) { + LOGPRINTF(_LOG_ERRNO, "malloc()"); + return -1; + } if ( fqdn_to_qname(parts[0], fqdn_len, qname, fqdn_len+2) < 0) { LOGPRINTF(_LOG_ERROR, "Failed to convert to QNAME. This is a bug."); return -1; -- cgit v1.2.3