]> granicus.if.org Git - linux-pam/commitdiff
Relevant BUGIDs:
authorThorsten Kukuk <kukuk@thkukuk.de>
Wed, 14 Jun 2006 21:20:48 +0000 (21:20 +0000)
committerThorsten Kukuk <kukuk@thkukuk.de>
Wed, 14 Jun 2006 21:20:48 +0000 (21:20 +0000)
Purpose of commit: cleanup

Commit summary:
---------------

2006-06-14  Thorsten Kukuk  <kukuk@thkukuk.de>

        * libpam/pam_misc.c (_pam_strdup): Use strlen and strcpy.

ChangeLog
libpam/pam_misc.c

index 2554bf428d3edd7826febf620a36ff1f746770d3..0923a816b316fd5901a5bf8e1a48aac9a1967727 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2006-06-14  Thorsten Kukuk  <kukuk@thkukuk.de>
 
+       * libpam/pam_misc.c (_pam_strdup): Use strlen and strcpy.
+
        * configure.in: Remove --enable-memory-debug, add option
        to disable prelude if installed.
 
index 78e317f756295220a811c630e132be6641ad5a2e..770c9ccef1a4bb5a1d352e192bf4d58454e081b3 100644 (file)
@@ -122,16 +122,14 @@ char *_pam_strdup(const char *x)
      register char *new=NULL;
 
      if (x != NULL) {
-         register int i;
+         register int len;
 
-         for (i=0; x[i]; ++i);                       /* length of string */
-         if ((new = malloc(++i)) == NULL) {
-              i = 0;
+         len = strlen (x) + 1;  /* length of string including NUL */
+         if ((new = malloc(len)) == NULL) {
+              len = 0;
               pam_syslog(NULL, LOG_CRIT, "_pam_strdup: failed to get memory");
          } else {
-              while (i-- > 0) {
-                   new[i] = x[i];
-              }
+              strcpy (new, x);
          }
          x = NULL;
      }