From 6f1713f216fef686a68db5ee02232bc67e525c7d Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 25 Feb 2008 23:23:58 +0000 Subject: *: intrduce and use safe_gethostname. By Tito safe_gethostname - 48 +48 glob3 35 37 +2 timestamp_and_log 314 315 +1 udhcp_send_kernel_packet 234 231 -3 scan_tree 275 271 -4 passwd_main 1074 1070 -4 print_login_prompt 68 58 -10 obscure 392 377 -15 syslogd_main 882 866 -16 print_login_issue 516 478 -38 hostname_main 278 223 -55 parse_and_put_prompt 825 756 -69 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/9 up/down: 51/-214) Total: -163 bytes text data bss dec hex filename 798791 728 7484 807003 c505b busybox_old 798631 728 7484 806843 c4fbb busybox_unstripped --- libbb/obscure.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'libbb/obscure.c') diff --git a/libbb/obscure.c b/libbb/obscure.c index 5cc906235..1841b27d6 100644 --- a/libbb/obscure.c +++ b/libbb/obscure.c @@ -93,7 +93,7 @@ static const char *obscure_msg(const char *old_p, const char *new_p, const struc /* Add 2 for each type of characters to the minlen of password */ int size = CONFIG_PASSWORD_MINLEN + 8; const char *p; - char hostname[255]; + char *hostname; /* size */ if (!new_p || (length = strlen(new_p)) < CONFIG_PASSWORD_MINLEN) @@ -108,12 +108,11 @@ static const char *obscure_msg(const char *old_p, const char *new_p, const struc return "similar to gecos"; } /* hostname as-is, as sub-string, reversed, capitalized, doubled */ - if (gethostname(hostname, 255) == 0) { - hostname[254] = '\0'; - if (string_checker(new_p, hostname)) { - return "similar to hostname"; - } - } + hostname = safe_gethostname(); + i = string_checker(new_p, hostname); + free(hostname); + if (i) + return "similar to hostname"; /* Should / Must contain a mix of: */ for (i = 0; i < length; i++) { -- cgit v1.2.3