libafscp: Use strdup, rather than rolling our own

A = malloc(strlen(B)+ 1);
   memset(A, 0, strlen(B) + 1);
   strlcpy(A, B, strlen(B) + 1);
can be more simply written as
   A = strdup(B);

Doing so also avoids a warning from clang that strlcpy isn't checking
for A overflowing.

Reviewed-on: http://gerrit.openafs.org/7077
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
(cherry picked from commit 1e30c00e7d9b45d65e819d39414939f2d5f7631b)

Change-Id: I886bef77fdedb63d1c83e657c25d112e0a635db2
Reviewed-on: http://gerrit.openafs.org/11844
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
Simon Wilkinson 2012-03-30 19:18:47 +01:00 committed by Stephan Wiesand
parent 7dff003299
commit 9a324f14e7

View File

@ -121,9 +121,7 @@ afscp_CellByName(const char *cellname, const char *realmname)
memset(thecell, 0, sizeof(struct afscp_cell));
strlcpy(thecell->name, cellname, sizeof(thecell->name));
if (realmname != NULL) {
thecell->realm = malloc(strlen(realmname) + 1);
memset(thecell->realm, 0, strlen(realmname) + 1);
strlcpy(thecell->realm, realmname, strlen(realmname) + 1);
thecell->realm = strdup(realmname);
} else {
thecell->realm = NULL;
}