Potential for NULL pointer de-reference (CWE-476) in file 'dnssec-keyfromlabel.c'
Summary
In reviewing calls to 'isc_mem_strdup()', in directory '/bin/dnssec' file 'dnssec-keyfromlabel.c' at line 221, there is a call made to 'isc_mem_strdup()' that is not checked for a return value of NULL, which potentially could cause a NULL pointer dereference
BIND version used
9.14.5
Steps to reproduce
Bug is in software
What is the current bug behavior?
If memory allocation fails, the end result could be a 'segmentation fault (core dumped)', the check added prevents this by a graceful exit...
What is the expected correct behavior?
All memory allocations should be checked to ensure the memory requested is actually returned.
Relevant configuration files
N/A
Relevant logs and/or screenshots
N/A
Possible fixes
Attaching patch file to this bug report...dnssec-keyfromlabel.c.patch
--- dnssec-keyfromlabel.c.orig 2019-09-04 19:09:14.010784200 -0700
+++ dnssec-keyfromlabel.c 2019-09-04 19:11:05.835919500 -0700
@@ -221,6 +221,8 @@
break;
case 'l':
label = isc_mem_strdup(mctx, isc_commandline_argument);
+ if (label == NULL)
+ fatal("out of memory");
break;
case 'n':
nametype = isc_commandline_argument;