Been chasing a bug we added to busybox ourselfs :(
The applet is login.  We added some extra functionality to that applet.
I could provide details if there is intrest.

Bottom line is we used variable 'opt_host' without ensuring
'(opt & LOGIN_OPT_h)' was true.

Talked to the gcc-cris author, while chasing the bug, about one specific
declaration (which is supposed to keep gcc from warning about
uninitialized variables).  In this particular case:

  char *opt_host = opt_host; /* for compiler */

Yes, doing it like that saves some bytes but it is highly questionable if
it's TRT to do, as you can count on gcc-undeterministic behaviour (IOW, be
prepared for surprises).  Proper thing to do would be:

  char *opt_host = NULL;

Yes, it will cost some bytes in each place that construct is used, but
doing it the right way will save some grief.

The attached patch adds bytes or shrinks the code depending on the gcc
version.  Number of bytes is (IIRC) -12 to +3.

Thoughts?


Cheers,

-- 
Cristian
Index: loginutils/login.c
===================================================================
--- loginutils/login.c	(revision 22297)
+++ loginutils/login.c	(working copy)
@@ -235,7 +235,7 @@
 	unsigned opt;
 	int count = 0;
 	struct passwd *pw;
-	char *opt_host = opt_host; /* for compiler */
+	char *opt_host = NULL; /* for compiler */
 	char *opt_user = opt_user; /* for compiler */
 	char full_tty[TTYNAME_SIZE];
 	USE_SELINUX(security_context_t user_sid = NULL;)
@@ -286,7 +286,7 @@
 
 	read_or_build_utent(&utent, !amroot);
 
-	if (opt & LOGIN_OPT_h) {
+	if (opt_host) {
 		USE_FEATURE_UTMP(
 			safe_strncpy(utent.ut_host, opt_host, sizeof(utent.ut_host));
 		)
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to