[PATCH] (do_auth): Rename local: s/buf/password/

Jim Meyering meyering at redhat.com
Tue Mar 4 05:09:52 PST 2008


Signed-off-by: Jim Meyering <meyering at redhat.com>
---
 src/polkit-grant/polkit-grant-helper-shadow.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/polkit-grant/polkit-grant-helper-shadow.c b/src/polkit-grant/polkit-grant-helper-shadow.c
index 9586c5f..d9d3ef1 100644
--- a/src/polkit-grant/polkit-grant-helper-shadow.c
+++ b/src/polkit-grant/polkit-grant-helper-shadow.c
@@ -126,19 +126,19 @@ error:
 int do_auth (const char *user_to_auth)
 {
         struct spwd *shadow;
-        char buf[256];
+        char password[256];

         if ((shadow = getspnam (user_to_auth)) == NULL)
                 goto error;

-        if (fgets (buf, sizeof (buf), stdin) == NULL)
+        if (fgets (password, sizeof (password), stdin) == NULL)
                 goto error;

-        if (strlen (buf) > 0 &&
-                buf[strlen (buf) - 1] == '\n')
-                        buf[strlen (buf) - 1] = '\0';
+        if (strlen (password) > 0 &&
+                password[strlen (password) - 1] == '\n')
+                        password[strlen (password) - 1] = '\0';

-        if (strcmp (shadow->sp_pwdp, crypt (buf, shadow->sp_pwdp)) != 0)
+        if (strcmp (shadow->sp_pwdp, crypt (password, shadow->sp_pwdp)) != 0)
                 goto error;

         return 1;
-- 
1.5.4.3.448.ga661


--=-=-=


--------------------------------------------------------------
The use of "strdup" here would have leaked, and is unnecessary anyway.

Avoid unnecessary/leaky use of strdup.
* polkit-grant-helper.c (main): Move the declaration of "buf"
to the outer scope and use a pointer into it, instead.

--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
 filename=0004-Avoid-unnecessary-leaky-use-of-strdup.patch



More information about the hal mailing list