- bzero -> memset

text    data     bss     dec     hex filename
1652855   14444 1215616 2882915  2bfd63 busybox.oorig.gcc-3.3
1652823   14444 1215616 2882883  2bfd43 busybox.gcc-3.3
1603655   14412 1215552 2833619  2b3cd3 busybox.oorig.gcc-3.4
1603655   14412 1215552 2833619  2b3cd3 busybox.gcc-3.4
1609755   14508 1215744 2840007  2b55c7 busybox.oorig.gcc-4.0
1609755   14508 1215744 2840007  2b55c7 busybox.gcc-4.0
1590495   13516 1215392 2819403  2b054b busybox.oorig.gcc-4.1-HEAD
1590495   13516 1215392 2819403  2b054b busybox.gcc-4.1-HEAD
1589079   13036 1213248 2815363  2af583 busybox.oorig.gcc-4.2-HEAD
1589079   13036 1213248 2815363  2af583 busybox.gcc-4.2-HEAD
This commit is contained in:
Bernhard Reutner-Fischer
2006-01-31 17:57:48 +00:00
parent 87be316149
commit 3038557649
4 changed files with 29 additions and 41 deletions

View File

@@ -5,19 +5,7 @@
* Copyright (c) 1989 * Copyright (c) 1989
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* Original copyright notice is retained at the end of this file. * Original copyright notice is retained at the end of this file.
*/ */
@@ -398,7 +386,7 @@ static u_char *get(void)
} }
return ((u_char *) NULL); return ((u_char *) NULL);
} }
bzero((char *) curp + nread, need); memset((char *) curp + nread, 0, need);
eaddress = address + nread; eaddress = address + nread;
return (curp); return (curp);
} }

View File

@@ -45,7 +45,7 @@ static int update_passwd(const struct passwd *pw, const char *crypt_pw)
struct stat sb; struct stat sb;
struct flock lock; struct flock lock;
#ifdef CONFIG_FEATURE_SHADOWPASSWDS #if ENABLE_FEATURE_SHADOWPASSWDS
if (access(bb_path_shadow_file, F_OK) == 0) { if (access(bb_path_shadow_file, F_OK) == 0) {
snprintf(filename, sizeof filename, "%s", bb_path_shadow_file); snprintf(filename, sizeof filename, "%s", bb_path_shadow_file);
} else } else
@@ -93,8 +93,9 @@ static int update_passwd(const struct passwd *pw, const char *crypt_pw)
rewind(fp); rewind(fp);
while (!feof(fp)) { while (!feof(fp)) {
fgets(buffer, sizeof buffer, fp); fgets(buffer, sizeof buffer, fp);
if (!continued) { // Check to see if we're updating this line. if (!continued) { /* Check to see if we're updating this line. */
if (strncmp(username, buffer, strlen(username)) == 0) { // we have a match. if (strncmp(username, buffer, strlen(username)) == 0) {
/* we have a match. */
pw_rest = strchr(buffer, ':'); pw_rest = strchr(buffer, ':');
*pw_rest++ = '\0'; *pw_rest++ = '\0';
pw_rest = strchr(pw_rest, ':'); pw_rest = strchr(pw_rest, ':');
@@ -110,7 +111,7 @@ static int update_passwd(const struct passwd *pw, const char *crypt_pw)
} else { } else {
continued = 1; continued = 1;
} }
bzero(buffer, sizeof buffer); memset(buffer, 0, sizeof buffer);
} }
if (fflush(out_fp) || fsync(fileno(out_fp)) || fclose(out_fp)) { if (fflush(out_fp) || fsync(fileno(out_fp)) || fclose(out_fp)) {
@@ -145,9 +146,9 @@ extern int passwd_main(int argc, char **argv)
int dflg = 0; /* -d - delete password */ int dflg = 0; /* -d - delete password */
const struct passwd *pw; const struct passwd *pw;
#ifdef CONFIG_FEATURE_SHADOWPASSWDS #if ENABLE_FEATURE_SHADOWPASSWDS
const struct spwd *sp; const struct spwd *sp;
#endif /* CONFIG_FEATURE_SHADOWPASSWDS */ #endif
amroot = (getuid() == 0); amroot = (getuid() == 0);
openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
while ((flag = getopt(argc, argv, "a:dlu")) != EOF) { while ((flag = getopt(argc, argv, "a:dlu")) != EOF) {
@@ -186,7 +187,7 @@ extern int passwd_main(int argc, char **argv)
syslog(LOG_WARNING, "can't change pwd for `%s'", name); syslog(LOG_WARNING, "can't change pwd for `%s'", name);
bb_error_msg_and_die("Permission denied.\n"); bb_error_msg_and_die("Permission denied.\n");
} }
#ifdef CONFIG_FEATURE_SHADOWPASSWDS #if ENABLE_FEATURE_SHADOWPASSWDS
sp = getspnam(name); sp = getspnam(name);
if (!sp) { if (!sp) {
sp = (struct spwd *) pwd_to_spwd(pw); sp = (struct spwd *) pwd_to_spwd(pw);
@@ -196,7 +197,7 @@ extern int passwd_main(int argc, char **argv)
#else #else
cp = pw->pw_passwd; cp = pw->pw_passwd;
np = name; np = name;
#endif /* CONFIG_FEATURE_SHADOWPASSWDS */ #endif
safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd)); safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd));
if (!(dflg || lflg || uflg)) { if (!(dflg || lflg || uflg)) {
@@ -339,8 +340,8 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
return 1; return 1;
} }
safe_strncpy(orig, clear, sizeof(orig)); safe_strncpy(orig, clear, sizeof(orig));
bzero(clear, strlen(clear)); memset(clear, 0, strlen(clear));
bzero(cipher, strlen(cipher)); memset(cipher, 0, strlen(cipher));
} else { } else {
orig[0] = '\0'; orig[0] = '\0';
} }
@@ -348,12 +349,12 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
"Please use a combination of upper and lower case letters and numbers.\n" "Please use a combination of upper and lower case letters and numbers.\n"
"Enter new password: "))) "Enter new password: ")))
{ {
bzero(orig, sizeof orig); memset(orig, 0, sizeof orig);
/* return -1; */ /* return -1; */
return 1; return 1;
} }
safe_strncpy(pass, cp, sizeof(pass)); safe_strncpy(pass, cp, sizeof(pass));
bzero(cp, strlen(cp)); memset(cp, 0, strlen(cp));
/* if (!obscure(orig, pass, pw)) { */ /* if (!obscure(orig, pass, pw)) { */
if (obscure(orig, pass, pw)) { if (obscure(orig, pass, pw)) {
if (amroot) { if (amroot) {
@@ -364,7 +365,7 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
} }
} }
if (!(cp = bb_askpass(0, "Re-enter new password: "))) { if (!(cp = bb_askpass(0, "Re-enter new password: "))) {
bzero(orig, sizeof orig); memset(orig, 0, sizeof orig);
/* return -1; */ /* return -1; */
return 1; return 1;
} }
@@ -373,14 +374,14 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
/* return -1; */ /* return -1; */
return 1; return 1;
} }
bzero(cp, strlen(cp)); memset(cp, 0, strlen(cp));
bzero(orig, sizeof(orig)); memset(orig, 0, sizeof(orig));
if (algo == 1) { if (algo == 1) {
cp = pw_encrypt(pass, "$1$"); cp = pw_encrypt(pass, "$1$");
} else } else
cp = pw_encrypt(pass, crypt_make_salt()); cp = pw_encrypt(pass, crypt_make_salt());
bzero(pass, sizeof pass); memset(pass, 0, sizeof pass);
safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd)); safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd));
return 0; return 0;
} }

View File

@@ -17,7 +17,6 @@
#include "busybox.h" #include "busybox.h"
// sulogin defines
#define SULOGIN_PROMPT "\nGive root password for system maintenance\n" \ #define SULOGIN_PROMPT "\nGive root password for system maintenance\n" \
"(or type Control-D for normal startup):" "(or type Control-D for normal startup):"
@@ -41,7 +40,7 @@ static const char * const forbid[] = {
static void catchalarm(int junk) static void catchalarm(int ATTRIBUTE_UNUSED junk)
{ {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@@ -59,9 +58,9 @@ extern int sulogin_main(int argc, char **argv)
struct passwd pwent; struct passwd pwent;
struct passwd *pwd; struct passwd *pwd;
const char * const *p; const char * const *p;
#ifdef CONFIG_FEATURE_SHADOWPASSWDS #if ENABLE_FEATURE_SHADOWPASSWDS
struct spwd *spwd = NULL; struct spwd *spwd = NULL;
#endif /* CONFIG_FEATURE_SHADOWPASSWDS */ #endif
openlog("sulogin", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); openlog("sulogin", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
if (argc > 1) { if (argc > 1) {
@@ -114,7 +113,7 @@ extern int sulogin_main(int argc, char **argv)
bb_error_msg_and_die("No password entry for `root'\n"); bb_error_msg_and_die("No password entry for `root'\n");
} }
pwent = *pwd; pwent = *pwd;
#ifdef CONFIG_FEATURE_SHADOWPASSWDS #if ENABLE_FEATURE_SHADOWPASSWDS
spwd = NULL; spwd = NULL;
if (pwd && ((strcmp(pwd->pw_passwd, "x") == 0) if (pwd && ((strcmp(pwd->pw_passwd, "x") == 0)
|| (strcmp(pwd->pw_passwd, "*") == 0))) { || (strcmp(pwd->pw_passwd, "*") == 0))) {
@@ -124,7 +123,7 @@ extern int sulogin_main(int argc, char **argv)
pwent.pw_passwd = spwd->sp_pwdp; pwent.pw_passwd = spwd->sp_pwdp;
} }
} }
#endif /* CONFIG_FEATURE_SHADOWPASSWDS */ #endif
while (1) { while (1) {
cp = bb_askpass(timeout, SULOGIN_PROMPT); cp = bb_askpass(timeout, SULOGIN_PROMPT);
if (!cp || !*cp) { if (!cp || !*cp) {
@@ -134,7 +133,7 @@ extern int sulogin_main(int argc, char **argv)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else { } else {
safe_strncpy(pass, cp, sizeof(pass)); safe_strncpy(pass, cp, sizeof(pass));
bzero(cp, strlen(cp)); memset(cp, 0, strlen(cp));
} }
if (strcmp(pw_encrypt(pass, pwent.pw_passwd), pwent.pw_passwd) == 0) { if (strcmp(pw_encrypt(pass, pwent.pw_passwd), pwent.pw_passwd) == 0) {
break; break;
@@ -144,13 +143,13 @@ extern int sulogin_main(int argc, char **argv)
fflush(stdout); fflush(stdout);
syslog(LOG_WARNING, "Incorrect root password\n"); syslog(LOG_WARNING, "Incorrect root password\n");
} }
bzero(pass, strlen(pass)); memset(pass, 0, strlen(pass));
signal(SIGALRM, SIG_DFL); signal(SIGALRM, SIG_DFL);
puts("Entering System Maintenance Mode\n"); puts("Entering System Maintenance Mode\n");
fflush(stdout); fflush(stdout);
syslog(LOG_INFO, "System Maintenance Mode\n"); syslog(LOG_INFO, "System Maintenance Mode\n");
#ifdef CONFIG_SELINUX #if ENABLE_SELINUX
renew_current_security_context(); renew_current_security_context();
#endif #endif

View File

@@ -1342,7 +1342,7 @@ xbsd_write_bootstrap (void)
bcopy (d, &dl, sizeof (struct xbsd_disklabel)); bcopy (d, &dl, sizeof (struct xbsd_disklabel));
/* The disklabel will be overwritten by 0's from bootxx anyway */ /* The disklabel will be overwritten by 0's from bootxx anyway */
bzero (d, sizeof (struct xbsd_disklabel)); memset (d, 0, sizeof (struct xbsd_disklabel));
snprintf (path, sizeof(path), "%s/boot%s", bootdir, dkbasename); snprintf (path, sizeof(path), "%s/boot%s", bootdir, dkbasename);
if (!xbsd_get_bootstrap (path, &disklabelbuffer[xbsd_dlabel.d_secsize], if (!xbsd_get_bootstrap (path, &disklabelbuffer[xbsd_dlabel.d_secsize],
@@ -1457,7 +1457,7 @@ xbsd_initlabel (struct partition *p, struct xbsd_disklabel *d) {
struct xbsd_partition *pp; struct xbsd_partition *pp;
get_geometry (); get_geometry ();
bzero (d, sizeof (struct xbsd_disklabel)); memset (d, 0, sizeof (struct xbsd_disklabel));
d -> d_magic = BSD_DISKMAGIC; d -> d_magic = BSD_DISKMAGIC;