On Wed, Apr 05, 2017 at 11:56:29AM +0200, Ruediger Meier wrote: > From: Ruediger Meier <ruediger.meier@xxxxxxxxxxx> > > test libfdisk/gpt failed since bb676203 because UINT32_MAX does > not fit into ssize_t on 32bit systems. > > This patch rewrites parts of commit f71b96bf. Also handling > multiplication overflow and some typos. Note that it still looks > questionable that we would try to read() SSIZE_MAX bytes in > gpt_read_entries(). Maybe it would be better to have #define FDISK_GPT_NENTRIES_MAX (SIZE_MAX/sizeof(struct gpt_entry)) to avoid all the checks. We have to be able to store the entries array to the memory, so all should be based on this fact. Things like uint64_t sz; ... ret = calloc(1, sz); are just crazy fun... It also seems that the code does not care if header->sizeof_partition_entry is the same as sizeof(struct gpt_entry), but we use the array as "struct gpt_entry". The really correct way is to use (char *)buf + i * header->sizeof_partition_entry to get the entry. I'll play with it and send a patch for review. Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html