diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2007-04-05 15:05:52 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2007-04-05 15:05:52 -0700 |
commit | cd900e40b5676874d076c35466fd7baa6a49b1f6 (patch) | |
tree | c04168c7db0fcb3e401f09ce4d30a13dd65e7712 /src/iceauth.c | |
parent | 27f9a9324d58c9a7472c724c62f5b7ea0e1f4681 (diff) |
Replace many malloc(strlen()); strcpy() pairs with strdup()
Diffstat (limited to 'src/iceauth.c')
-rw-r--r-- | src/iceauth.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/iceauth.c b/src/iceauth.c index 38500a5..dcee7ed 100644 --- a/src/iceauth.c +++ b/src/iceauth.c @@ -135,12 +135,10 @@ char **errorStringRet; if (!data) { - char *tempstr = + const char *tempstr = "Could not find correct MIT-MAGIC-COOKIE-1 authentication"; - *errorStringRet = (char *) malloc (strlen (tempstr) + 1); - if (*errorStringRet) - strcpy (*errorStringRet, tempstr); + *errorStringRet = strdup(tempstr); return (IcePoAuthFailed); } @@ -161,11 +159,10 @@ char **errorStringRet; * a single pass authentication method. */ - char *tempstr = "MIT-MAGIC-COOKIE-1 authentication internal error"; + const char *tempstr = + "MIT-MAGIC-COOKIE-1 authentication internal error"; - *errorStringRet = (char *) malloc (strlen (tempstr) + 1); - if (*errorStringRet) - strcpy (*errorStringRet, tempstr); + *errorStringRet = strdup(tempstr); return (IcePoAuthFailed); } @@ -226,11 +223,10 @@ char **errorStringRet; } else { - char *tempstr = "MIT-MAGIC-COOKIE-1 authentication rejected"; + const char *tempstr + = "MIT-MAGIC-COOKIE-1 authentication rejected"; - *errorStringRet = (char *) malloc (strlen (tempstr) + 1); - if (*errorStringRet) - strcpy (*errorStringRet, tempstr); + *errorStringRet = strdup(tempstr); stat = IcePaAuthRejected; } @@ -246,12 +242,10 @@ char **errorStringRet; * always find a valid entry. */ - char *tempstr = + const char *tempstr = "MIT-MAGIC-COOKIE-1 authentication internal error"; - *errorStringRet = (char *) malloc (strlen (tempstr) + 1); - if (*errorStringRet) - strcpy (*errorStringRet, tempstr); + *errorStringRet = strdup(tempstr); return (IcePaAuthFailed); } |