From 0a2963a2ac89fa1e6fa7dd5638807c9cbd183469 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 5 May 2015 09:26:32 +0000 Subject: [PATCH] Use stdup(3) and check its return instead from homebrew version using strcpy(3) and malloc(3) Obtained from: NetBSD --- usr.bin/checknr/checknr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/checknr/checknr.c b/usr.bin/checknr/checknr.c index afc70cc5cd4..01d3216afc5 100644 --- a/usr.bin/checknr/checknr.c +++ b/usr.bin/checknr/checknr.c @@ -574,7 +574,8 @@ addmac(const char *mac) dest = src+1; while (dest > loc) *dest-- = *src--; - *loc = strcpy(malloc(3), mac); + if ((*loc = strdup(mac)) == NULL) + err(1, "strdup"); ncmds++; #ifdef DEBUG printf("after: %s %s %s %s %s, %d cmds\n",