Skip to content

Commit d0df930

Browse files
committed
Minor coverity fixes
- one missing free - one minor deadcode issue - two unchecked allocations - one debug hexdump of a variable we just freed Signed-off-by: Peter Jones <[email protected]>
1 parent 2e78cd9 commit d0df930

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

MokManager.c

+1
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ static void show_x509_info(X509 * X509Cert, UINT8 * hash)
339339
for (i = 0; i < n; i++) {
340340
CatPrint(&serial_string, L"%02x:", hexbuf[i]);
341341
}
342+
BN_free(bnser);
342343
}
343344

344345
if (serial_string.str)

fallback.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,11 @@ add_boot_option(EFI_DEVICE_PATH *hddp, EFI_DEVICE_PATH *fulldp,
230230
StrLen(label)*2 + 2 + DevicePathSize(hddp) +
231231
StrLen(arguments) * 2;
232232

233-
CHAR8 *data = AllocateZeroPool(size + 2);
234-
CHAR8 *cursor = data;
233+
CHAR8 *data, *cursor;
234+
cursor = data = AllocateZeroPool(size + 2);
235+
if (!data)
236+
return EFI_OUT_OF_RESOURCES;
237+
235238
*(UINT32 *)cursor = LOAD_OPTION_ACTIVE;
236239
cursor += sizeof (UINT32);
237240
*(UINT16 *)cursor = DevicePathSize(hddp);

include/hexdump.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ prepare_text(const void *data, size_t size, char *buf, unsigned int position)
7171
else
7272
buf[offset++] = '.';
7373
}
74-
buf[offset++] = size > 0 ? '|' : 'X';
74+
buf[offset++] = '|';
7575
buf[offset] = '\0';
7676
}
7777

@@ -89,6 +89,11 @@ vhexdumpf(const char *file, int line, const char *func, const CHAR16 *const fmt,
8989
if (verbose == 0)
9090
return;
9191

92+
if (!data || !size) {
93+
dprint(L"hexdump of a NULL pointer!\n");
94+
return;
95+
}
96+
9297
while (offset < size) {
9398
char hexbuf[49];
9499
char txtbuf[19];

lib/variables.c

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ fill_esl_with_one_signature(const uint8_t *data, const uint32_t data_len,
6868

6969
if (out) {
7070
sd = AllocateZeroPool(sig_size);
71+
if (!sd)
72+
return EFI_OUT_OF_RESOURCES;
7173
if (owner)
7274
CopyMem(sd, (void *)owner, sizeof(EFI_GUID));
7375
CopyMem(sd->SignatureData, (void *)data, data_len);

mok.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,9 @@ EFI_STATUS import_one_mok_state(struct mok_state_variable *v,
883883
}
884884

885885
dprint(L"maybe mirroring \"%s\". original data:\n", v->name);
886-
dhexdumpat(v->data, v->data_size, 0);
886+
if (v->data && v->data_size) {
887+
dhexdumpat(v->data, v->data_size, 0);
888+
}
887889

888890
ret = maybe_mirror_one_mok_variable(v, ret, only_first);
889891
dprint(L"returning %r\n", ret);

0 commit comments

Comments
 (0)