efi_loader: memory leak in append value
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Tue, 30 Apr 2019 05:14:09 +0000 (07:14 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 2 May 2019 16:17:50 +0000 (18:17 +0200)
When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
cmd/nvedit_efi.c

index e65b38dbf399b9fbb22969de561b3abb2d215d04..2805e8182b41fbafba75d44724b1c7b1933eb5d5 100644 (file)
@@ -291,8 +291,11 @@ static int append_value(char **bufp, size_t *sizep, char *data)
                if (!tmp_buf)
                        return -1;
 
-               if (hex2bin((u8 *)tmp_buf, data, len) < 0)
+               if (hex2bin((u8 *)tmp_buf, data, len) < 0) {
+                       printf("Error: illegal hexadecimal string\n");
+                       free(tmp_buf);
                        return -1;
+               }
 
                value = tmp_buf;
        } else { /* string */