libfdisk: (gpt) care about SSIZE_MAX for read(2)
read(2) behavior is undefined if you want to read more than SSIZE_MAX bytes. Let's be paranoid and check for this... Reported-by: Ruediger Meier <sweet_f_a@gmx.de> Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
9e320545bb
commit
a8294f401f
|
@ -874,6 +874,11 @@ static unsigned char *gpt_read_entries(struct fdisk_context *cxt,
|
||||||
if (gpt_sizeof_ents(header, &sz))
|
if (gpt_sizeof_ents(header, &sz))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (sz > (size_t) SSIZE_MAX) {
|
||||||
|
DBG(LABEL, ul_debug("GPT entries array too large to read()"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ret = calloc(1, sz);
|
ret = calloc(1, sz);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue