From 8d3c1246b8338c3fb3dbb53bcbfbe1fc0b183206 Mon Sep 17 00:00:00 2001 From: Dima Dorfman Date: Sun, 24 Jun 2001 18:21:52 +0000 Subject: [PATCH] Use strdup(3) instead of reimplementing it inline. --- sbin/mdmfs/mdmfs.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sbin/mdmfs/mdmfs.c b/sbin/mdmfs/mdmfs.c index 3b55ed9eed20..003aa80490cc 100644 --- a/sbin/mdmfs/mdmfs.c +++ b/sbin/mdmfs/mdmfs.c @@ -475,25 +475,19 @@ extract_ugid(const char *str, struct mtpt_info *mip) { char *ug; /* Writable 'str'. */ char *user, *group; /* Result of extracton. */ - size_t strl; /* Length of 'str' incl. NULL. */ struct passwd *pw; struct group *gr; char *p; uid_t *uid; gid_t *gid; - size_t rv; uid = &mip->mi_uid; gid = &mip->mi_gid; mip->mi_have_uid = mip->mi_have_gid = false; /* Extract the user and group from 'str'. Format above. */ - strl = strlen(str) + 1; - ug = malloc(strl); + ug = strdup(str); assert(ug != NULL); - rv = strlcpy(ug, str, strl); - if (rv >= strl) - errx(1, "-w word too long (%ld >= %ld)", (long)rv, (long)strl); group = ug; user = strsep(&group, ":"); if (user == NULL || group == NULL || *user == '\0' || *group == '\0')