mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 05:27:44 +00:00
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:
parent
7dff003299
commit
9a324f14e7
@ -121,9 +121,7 @@ afscp_CellByName(const char *cellname, const char *realmname)
|
|||||||
memset(thecell, 0, sizeof(struct afscp_cell));
|
memset(thecell, 0, sizeof(struct afscp_cell));
|
||||||
strlcpy(thecell->name, cellname, sizeof(thecell->name));
|
strlcpy(thecell->name, cellname, sizeof(thecell->name));
|
||||||
if (realmname != NULL) {
|
if (realmname != NULL) {
|
||||||
thecell->realm = malloc(strlen(realmname) + 1);
|
thecell->realm = strdup(realmname);
|
||||||
memset(thecell->realm, 0, strlen(realmname) + 1);
|
|
||||||
strlcpy(thecell->realm, realmname, strlen(realmname) + 1);
|
|
||||||
} else {
|
} else {
|
||||||
thecell->realm = NULL;
|
thecell->realm = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user