svn commit: branches/busybox_1_9_stable: editors init libbb networking networking etc...
vda at busybox.net
vda at busybox.net
Fri Mar 21 02:44:02 PDT 2008
Author: vda
Date: 2008-03-21 02:44:02 -0700 (Fri, 21 Mar 2008)
New Revision: 21434
Log:
apply five post-1.9.1 patches
Modified:
branches/busybox_1_9_stable/editors/patch.c
branches/busybox_1_9_stable/init/init.c
branches/busybox_1_9_stable/libbb/lineedit.c
branches/busybox_1_9_stable/networking/httpd.c
branches/busybox_1_9_stable/networking/udhcp/files.c
Changeset:
Modified: branches/busybox_1_9_stable/editors/patch.c
===================================================================
--- branches/busybox_1_9_stable/editors/patch.c 2008-03-21 08:51:00 UTC (rev 21433)
+++ branches/busybox_1_9_stable/editors/patch.c 2008-03-21 09:44:02 UTC (rev 21434)
@@ -71,12 +71,6 @@
return xstrdup(filename_start_ptr);
}
-static int file_doesnt_exist(const char *filename)
-{
- struct stat statbuf;
- return stat(filename, &statbuf);
-}
-
int patch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int patch_main(int argc, char **argv)
{
@@ -84,7 +78,8 @@
char *patch_line;
int ret;
FILE *patch_file = NULL;
-
+ struct stat saved_stat;
+
{
char *p, *i;
ret = getopt32(argv, "p:i:", &p, &i);
@@ -134,8 +129,9 @@
}
new_filename = extract_filename(patch_line, patch_level);
free(patch_line);
-
- if (file_doesnt_exist(new_filename)) {
+
+ /* Get access rights from the file to be patched, -1 file does not exist */
+ if (stat(new_filename, &saved_stat)) {
char *line_ptr;
/* Create leading directories */
line_ptr = strrchr(new_filename, '/');
@@ -155,9 +151,10 @@
backup_filename);
}
dst_stream = xfopen(new_filename, "w");
+ fchmod(fileno(dst_stream), saved_stat.st_mode);
}
- if ((backup_filename == NULL) || file_doesnt_exist(original_filename)) {
+ if ((backup_filename == NULL) || stat(original_filename, &saved_stat)) {
src_stream = NULL;
} else {
if (strcmp(original_filename, new_filename) == 0) {
Modified: branches/busybox_1_9_stable/init/init.c
===================================================================
--- branches/busybox_1_9_stable/init/init.c 2008-03-21 08:51:00 UTC (rev 21433)
+++ branches/busybox_1_9_stable/init/init.c 2008-03-21 09:44:02 UTC (rev 21434)
@@ -225,8 +225,22 @@
}
messageD(L_LOG, "console='%s'", s);
} else {
- /* Make sure fd 0,1,2 are not closed */
- bb_sanitize_stdio();
+ /* Make sure fd 0,1,2 are not closed
+ * (so that they won't be used by future opens) */
+
+ /* bb_sanitize_stdio(); - WRONG.
+ * Fail if "/dev/null" doesnt exist, and for init
+ * this is a real possibility! Open code it instead. */
+
+ int fd = open(bb_dev_null, O_RDWR);
+ if (fd < 0) {
+ /* Give me _ANY_ open descriptor! */
+ fd = xopen("/", O_RDONLY); /* we don't believe this can fail */
+ }
+ while ((unsigned)fd < 2)
+ fd = dup(fd);
+ if (fd > 2)
+ close (fd);
}
s = getenv("TERM");
Modified: branches/busybox_1_9_stable/libbb/lineedit.c
===================================================================
--- branches/busybox_1_9_stable/libbb/lineedit.c 2008-03-21 08:51:00 UTC (rev 21433)
+++ branches/busybox_1_9_stable/libbb/lineedit.c 2008-03-21 09:44:02 UTC (rev 21434)
@@ -246,7 +246,15 @@
if (cmdedit_x >= num) {
cmdedit_x -= num;
if (num <= 4) {
- printf("\b\b\b\b" + (4-num));
+ /* This is longer by 5 bytes on x86.
+ * Also gets mysteriously
+ * miscompiled for some ARM users.
+ * printf(("\b\b\b\b" + 4) - num);
+ * return;
+ */
+ do {
+ bb_putchar('\b');
+ } while (--num);
return;
}
printf("\033[%uD", num);
Modified: branches/busybox_1_9_stable/networking/httpd.c
===================================================================
--- branches/busybox_1_9_stable/networking/httpd.c 2008-03-21 08:51:00 UTC (rev 21433)
+++ branches/busybox_1_9_stable/networking/httpd.c 2008-03-21 09:44:02 UTC (rev 21434)
@@ -1950,7 +1950,7 @@
if ((STRNCASECMP(iobuf, "Content-length:") == 0)) {
/* extra read only for POST */
if (prequest != request_GET) {
- tptr = iobuf + sizeof("Content-length:") - 1;
+ tptr = tptr = skip_whitespace(iobuf + sizeof("Content-length:") - 1);
if (!tptr[0])
send_headers_and_exit(HTTP_BAD_REQUEST);
errno = 0;
Modified: branches/busybox_1_9_stable/networking/udhcp/files.c
===================================================================
--- branches/busybox_1_9_stable/networking/udhcp/files.c 2008-03-21 08:51:00 UTC (rev 21433)
+++ branches/busybox_1_9_stable/networking/udhcp/files.c 2008-03-21 09:44:02 UTC (rev 21434)
@@ -167,7 +167,7 @@
if (!opt)
return 0;
- idx = index_in_strings(opt, dhcp_option_strings); /* NB: was strcasecmp! */
+ idx = index_in_strings(dhcp_option_strings, opt); /* NB: was strcasecmp! */
if (idx < 0)
return 0;
option = &dhcp_options[idx];
More information about the busybox-cvs
mailing list