[BusyBox-cvs] busybox/libbb Makefile.in,1.21,1.22 copy_file.c,1.24,1.25 find_root_device.c,1.6,1.7 isdirectory.c,1.3,1.4 login.c,1.3,1.4 pw_encrypt.c,1.1,1.2 recursive_action.c,1.8,1.9 remove_file.c,1.5,1.6 run_shell.c,1.3,1.4 setup_environment.c,1.2,1.3 xgetcwd.c,1.4,1.5

Glenn McGrath bug1 at busybox.net
Mon May 26 14:06:04 UTC 2003


Update of /var/cvs/busybox/libbb
In directory winder:/tmp/cvs-serv10512/libbb

Modified Files:
	Makefile.in copy_file.c find_root_device.c isdirectory.c 
	login.c pw_encrypt.c recursive_action.c remove_file.c 
	run_shell.c setup_environment.c xgetcwd.c 
Log Message:
Vodz, last_patch_86


Index: Makefile.in
===================================================================
RCS file: /var/cvs/busybox/libbb/Makefile.in,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- Makefile.in	16 Apr 2003 23:02:35 -0000	1.21
+++ Makefile.in	26 May 2003 14:06:00 -0000	1.22
@@ -48,7 +48,7 @@
 	fclose_nonstdin.c fflush_stdout_and_exit.c getopt_ulflags.c \
 	default_error_retval.c wfopen_input.c speed_table.c \
 	perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c \
-	warn_ignoring_args.c
+	warn_ignoring_args.c concat_subpath_file.c
 
 LIBBB_OBJS=$(patsubst %.c,$(LIBBB_DIR)%.o, $(LIBBB_SRC))
 

Index: copy_file.c
===================================================================
RCS file: /var/cvs/busybox/libbb/copy_file.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- copy_file.c	19 Mar 2003 09:12:06 -0000	1.24
+++ copy_file.c	26 May 2003 14:06:00 -0000	1.25
@@ -105,11 +105,9 @@
 		while ((d = readdir(dp)) != NULL) {
 			char *new_source, *new_dest;
 
-			if (strcmp(d->d_name, ".") == 0 ||
-					strcmp(d->d_name, "..") == 0)
+			new_source = concat_subpath_file(source, d->d_name);
+			if(new_source == NULL)
 				continue;
-
-			new_source = concat_path_file(source, d->d_name);
 			new_dest = concat_path_file(dest, d->d_name);
 			if (copy_file(new_source, new_dest, flags) < 0)
 				status = -1;

Index: find_root_device.c
===================================================================
RCS file: /var/cvs/busybox/libbb/find_root_device.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- find_root_device.c	19 Mar 2003 09:12:06 -0000	1.6
+++ find_root_device.c	26 May 2003 14:06:00 -0000	1.7
@@ -49,12 +49,9 @@
 		else {
 			while((entry = readdir(dir)) != NULL) {
 
-				/* Must skip ".." since that is "/", and so we 
-				 * would get a false positive on ".."  */
-				if (strcmp(entry->d_name, "..") == 0)
+				fileName = concat_subpath_file("/dev", entry->d_name);
+				if(fileName == NULL)
 					continue;
-
-				fileName = concat_path_file("/dev", entry->d_name);
 
 				/* Some char devices have the same dev_t as block
 				 * devices, so make sure this is a block device */

Index: isdirectory.c
===================================================================
RCS file: /var/cvs/busybox/libbb/isdirectory.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- isdirectory.c	20 Dec 2001 23:13:03 -0000	1.3
+++ isdirectory.c	26 May 2003 14:06:00 -0000	1.4
@@ -20,8 +20,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <sys/stat.h>
 #include "libbb.h"
 
@@ -32,11 +30,11 @@
 int is_directory(const char *fileName, const int followLinks, struct stat *statBuf)
 {
 	int status;
-	int didMalloc = 0;
+	struct stat astatBuf;
 
 	if (statBuf == NULL) {
-	    statBuf = (struct stat *)xmalloc(sizeof(struct stat));
-	    ++didMalloc;
+	    /* set from auto stack buffer */
+	    statBuf = &astatBuf;
 	}
 
 	if (followLinks)
@@ -49,10 +47,6 @@
 	}
 	else status = TRUE;
 
-	if (didMalloc) {
-	    free(statBuf);
-	    statBuf = NULL;
-	}
 	return status;
 }
 

Index: login.c
===================================================================
RCS file: /var/cvs/busybox/libbb/login.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- login.c	13 May 2003 13:28:25 -0000	1.3
+++ login.c	26 May 2003 14:06:00 -0000	1.4
@@ -17,26 +17,28 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
- * $Id$
+ * Optimize and correcting OCRNL by Vladimir Oleynik <dzo at simtreas.ru>
  */
 
+#include <sys/param.h>  /* MAXHOSTNAMELEN */
 #include <stdio.h>
 #include <unistd.h>
-#include "busybox.h"
+#include "libbb.h"
 
 #include <sys/utsname.h>
 #include <time.h>
 
 #define LOGIN " login: "
 
-static char fmtstr_d[] = { "%A, %d %B %Y" };
-static char fmtstr_t[] = { "%H:%M:%S" };
+static const char fmtstr_d[] = "%A, %d %B %Y";
+static const char fmtstr_t[] = "%H:%M:%S";
 
 void print_login_issue(const char *issue_file, const char *tty)
 {
 	FILE *fd;
 	int c;
 	char buf[256];
+	const char *outbuf;
 	time_t t;
 	struct utsname uts;
 
@@ -47,73 +49,75 @@
 
 	if ((fd = fopen(issue_file, "r"))) {
 		while ((c = fgetc(fd)) != EOF) {
+			outbuf = buf;
+			buf[0] = c;
+			if(c == '\n') {
+				buf[1] = '\r';
+				buf[2] = 0;
+			} else {
+				buf[1] = 0;
+			}
 			if (c == '\\' || c == '%') {
 				c = fgetc(fd);
-
 				switch (c) {
 					case 's':
-						fputs(uts.sysname, stdout);
+						outbuf = uts.sysname;
 						break;
 
 					case 'n':
-						fputs(uts.nodename, stdout);
+						outbuf = uts.nodename;
 						break;
 
 					case 'r':
-						fputs(uts.release, stdout);
+						outbuf = uts.release;
 						break;
 
 					case 'v':
-						fputs(uts.version, stdout);
+						outbuf = uts.version;
 						break;
 
 					case 'm':
-						fputs(uts.machine, stdout);
+						outbuf = uts.machine;
 						break;
 
 					case 'D':
 					case 'o':
 						getdomainname(buf, sizeof(buf));
 						buf[sizeof(buf) - 1] = '\0';
-						fputs(buf, stdout);
 						break;
 
 					case 'd':
 						strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
-						fputs(buf, stdout);
 						break;
 
 					case 't':
 						strftime(buf, sizeof(buf), fmtstr_t, localtime(&t));
-						fputs(buf, stdout);
 						break;
 
 					case 'h':
-						gethostname(buf, sizeof(buf));
-						fputs(buf, stdout);
+						gethostname(buf, sizeof(buf) - 1);
 						break;
 
 					case 'l':
-						printf("%s", tty);
+						outbuf = tty;
 						break;
 
 					default:
-						putchar(c);
+						buf[0] = c;
 				}
-			} else
-				putchar(c);
 		}
-
-		puts("");	/* start a new line */
-		fflush(stdout);
+			fputs(outbuf, stdout);
+		}
 
 		fclose(fd);
+
+		fflush(stdout);
 	}
 }
 
 void print_login_prompt(void)
 {
-	char buf[MAXHOSTNAMELEN];
+	char buf[MAXHOSTNAMELEN+1];
 
 	gethostname(buf, MAXHOSTNAMELEN);
 	fputs(buf, stdout);

Index: pw_encrypt.c
===================================================================
RCS file: /var/cvs/busybox/libbb/pw_encrypt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- pw_encrypt.c	23 Jun 2002 04:24:22 -0000	1.1
+++ pw_encrypt.c	26 May 2003 14:06:00 -0000	1.2
@@ -39,10 +39,7 @@
 	/* if crypt (a nonstandard crypt) returns a string too large,
 	   truncate it so we don't overrun buffers and hope there is
 	   enough security in what's left */
-	if (strlen(cp) > sizeof(cipher)-1) {
-		cp[sizeof(cipher)-1] = 0;
-	}
-	strcpy(cipher, cp);
+	safe_strncpy(cipher, cp, sizeof(cipher));
 	return cipher;
 }
 

Index: recursive_action.c
===================================================================
RCS file: /var/cvs/busybox/libbb/recursive_action.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- recursive_action.c	19 Mar 2003 09:12:08 -0000	1.8
+++ recursive_action.c	26 May 2003 14:06:00 -0000	1.9
@@ -103,11 +103,9 @@
 		while ((next = readdir(dir)) != NULL) {
 			char *nextFile;
 
-			if ((strcmp(next->d_name, "..") == 0)
-					|| (strcmp(next->d_name, ".") == 0)) {
+			nextFile = concat_subpath_file(fileName, next->d_name);
+			if(nextFile == NULL)
 				continue;
-			}
-			nextFile = concat_path_file(fileName, next->d_name);
 			if (! recursive_action(nextFile, TRUE, followLinks, depthFirst,
 						fileAction, dirAction, userData)) {
 				status = FALSE;

Index: remove_file.c
===================================================================
RCS file: /var/cvs/busybox/libbb/remove_file.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- remove_file.c	19 Mar 2003 09:12:08 -0000	1.5
+++ remove_file.c	26 May 2003 14:06:00 -0000	1.6
@@ -79,11 +79,9 @@
 		while ((d = readdir(dp)) != NULL) {
 			char *new_path;
 
-			if (strcmp(d->d_name, ".") == 0 ||
-					strcmp(d->d_name, "..") == 0)
+			new_path = concat_subpath_file(path, d->d_name);
+			if(new_path == NULL)
 				continue;
-
-			new_path = concat_path_file(path, d->d_name);
 			if (remove_file(new_path, flags) < 0)
 				status = -1;
 			free(new_path);

Index: run_shell.c
===================================================================
RCS file: /var/cvs/busybox/libbb/run_shell.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- run_shell.c	19 Mar 2003 09:12:08 -0000	1.3
+++ run_shell.c	26 May 2003 14:06:00 -0000	1.4
@@ -52,10 +52,7 @@
 	for ( args = additional_args; args && *args; args++ )
 		additional_args_cnt++;
 
-	if ( additional_args )
 		args = (const char **) xmalloc (sizeof (char *) * ( 4  + additional_args_cnt ));
-	else
-		args = (const char **) xmalloc (sizeof (char *) * 4 );
 		
 	args [0] = bb_get_last_path_component ( bb_xstrdup ( shell ));
 	
@@ -77,4 +74,3 @@
 	execv ( shell, (char **) args );
 	bb_perror_msg_and_die ( "cannot run %s", shell );
 }
-

Index: setup_environment.c
===================================================================
RCS file: /var/cvs/busybox/libbb/setup_environment.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- setup_environment.c	19 Mar 2003 09:12:08 -0000	1.2
+++ setup_environment.c	26 May 2003 14:06:00 -0000	1.3
@@ -45,13 +45,13 @@
 static void xsetenv ( const char *key, const char *value )
 {
 	    if ( setenv ( key, value, 1 ))
-			        bb_error_msg_and_die ( "out of memory" );
+				bb_error_msg_and_die (bb_msg_memory_exhausted);
 }
 
 void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw )
 {
 	if ( loginshell ) {
-		char *term;
+		const char *term;
 	
 		/* Change the current working directory to be the home directory
 		 * of the user.  It is a fatal error for this process to be unable

Index: xgetcwd.c
===================================================================
RCS file: /var/cvs/busybox/libbb/xgetcwd.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- xgetcwd.c	19 Mar 2003 09:12:09 -0000	1.4
+++ xgetcwd.c	26 May 2003 14:06:00 -0000	1.5
@@ -3,7 +3,7 @@
  * Copyright (C) 1992, 1996 Free Software Foundation, Inc.
  * Written by David MacKenzie <djm at gnu.ai.mit.edu>.
  *
- * Special function for busybox written by Vladimir Oleynik <vodz at usa.net>
+ * Special function for busybox written by Vladimir Oleynik <dzo at simtreas.ru>
 */
 
 #include <stdlib.h>



More information about the busybox-cvs mailing list