]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
vipw: use explicit_bzero() to clear buffer after copy
authorSami Kerola <kerolasa@iki.fi>
Sat, 29 Jul 2017 16:19:47 +0000 (17:19 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 5 Aug 2017 08:58:25 +0000 (09:58 +0100)
This should make leaking end of /etc/shadow file more unlikely.

Notice that there is now way to tell to editors they should ensure none it
does not leak any buffers, drop cores, and so on, when editing sensitive
data.  In short this change is addressing the issue only partially.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/vipw.c

index 5999d8d15081d1d59333adfe2795935dc906ccd2..b7650de8b98c78d658b1ede29b47489e97986f68 100644 (file)
@@ -100,6 +100,9 @@ static void copyfile(int from, int to)
 
        if (nr < 0)
                pw_error(orig_file, 1, 1);
+#ifdef HAVE_EXPLICIT_BZERO
+       explicit_bzero(buf, sizeof(buf));
+#endif
 }
 
 static void pw_init(void)