string. Don't rely on GPT partition name containing a terminating
zero or the reserved bytes beyond gp_name being properly
initialized to zero.
-/* $OpenBSD: gpt.c,v 1.92 2023/06/19 23:11:19 krw Exp $ */
+/* $OpenBSD: gpt.c,v 1.93 2023/06/20 11:52:08 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
static char name[GPTPARTNAMESIZE + 1];
unsigned int i;
- memset(name, 0, sizeof(name));
-
- for (i = 0; i < sizeof(name) && gp[pn].gp_name[i] != 0; i++)
+ for (i = 0; i < GPTPARTNAMESIZE && gp[pn].gp_name[i] != 0; i++)
name[i] = letoh16(gp[pn].gp_name[i]) & 0x7F;
+ name[i] = '\0';
return name;
}