summaryrefslogtreecommitdiff
path: root/sbin/fdisk
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2016-03-30 23:40:55 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2016-03-30 23:40:55 +0000
commit71c5b5638db3a9dc630e751572744952eee12715 (patch)
tree673697bb11a8326ef305d95e485a5b0d73ba656f /sbin/fdisk
parentbb8a088342dbb8ce495fcdc306d2e2aafba86ce3 (diff)
Dump strdup()/free() dance and just use a local buffer to translate help
messages to GPT. Unchecked strdup() result noted by mestre@. ok mestre@ tim@
Diffstat (limited to 'sbin/fdisk')
-rw-r--r--sbin/fdisk/cmd.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index 8dc71603089..a8ec0832b00 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.94 2016/03/28 18:14:01 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.95 2016/03/30 23:40:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -465,22 +465,20 @@ Xexit(char *args, struct mbr *mbr)
int
Xhelp(char *args, struct mbr *mbr)
{
- char *mbrstr, *gpthelp;
+ char help[80];
+ char *mbrstr;
int i;
for (i = 0; cmd_table[i].cmd != NULL; i++) {
+ strlcpy(help, cmd_table[i].help, sizeof(help));
if (letoh64(gh.gh_sig) == GPTSIGNATURE) {
if (cmd_table[i].gpt == 0)
continue;
- gpthelp = strdup(cmd_table[i].help);
- mbrstr = strstr(gpthelp, "MBR");
+ mbrstr = strstr(help, "MBR");
if (mbrstr)
memcpy(mbrstr, "GPT", 3);
- printf("\t%s\t\t%s\n", cmd_table[i].cmd, gpthelp);
- free(gpthelp);
- } else
- printf("\t%s\t\t%s\n", cmd_table[i].cmd,
- cmd_table[i].help);
+ }
+ printf("\t%s\t\t%s\n", cmd_table[i].cmd, help);
}
return (CMD_CONT);