/* calculate the size (bytes) of the entries array */
rc = gpt_calculate_sizeof_ents(gpt->pheader, entries, &new_size);
if (rc) {
- fdisk_warnx(cxt, _("The number of the partition has to be smaller than %zu."),
- UINT32_MAX / le32_to_cpu(gpt->pheader->sizeof_partition_entry));
+ uint32_t entry_size = le32_to_cpu(gpt->pheader->sizeof_partition_entry);
+
+ if (entry_size == 0)
+ fdisk_warnx(cxt, _("The partition entry size is zero."));
+ else
+ fdisk_warnx(cxt, _("The number of the partition has to be smaller than %zu."),
+ UINT32_MAX / entry_size);
return rc;
}