aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-07 17:11:04 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-07 17:11:04 +0200
commit868530ade244bf8162fb6a10816bd815b166d509 (patch)
tree874fa8d8b979ae95ca53badadfa614f0de4ed7ac
parentc3b34d8b39cae35fec8c6fb644d90dc80e574236 (diff)
downloadbusybox-w32-1_25_1.tar.gz
busybox-w32-1_25_1.tar.bz2
busybox-w32-1_25_1.zip
Apply post-1.25.0 patches, bump version to 1.25.11_25_1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--Makefile2
-rw-r--r--archival/gzip.c5
-rw-r--r--networking/libiproute/iproute.c3
-rw-r--r--networking/ntpd.c7
-rw-r--r--shell/hush.c88
5 files changed, 72 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 572da3d88..a519f3a7e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1VERSION = 1 1VERSION = 1
2PATCHLEVEL = 25 2PATCHLEVEL = 25
3SUBLEVEL = 0 3SUBLEVEL = 1
4EXTRAVERSION = 4EXTRAVERSION =
5NAME = Unnamed 5NAME = Unnamed
6 6
diff --git a/archival/gzip.c b/archival/gzip.c
index 8f1e4ff29..9e0bee815 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -2220,10 +2220,7 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
2220 opt >>= ENABLE_GUNZIP ? 7 : 5; /* drop cfv[dt]qn bits */ 2220 opt >>= ENABLE_GUNZIP ? 7 : 5; /* drop cfv[dt]qn bits */
2221 if (opt == 0) 2221 if (opt == 0)
2222 opt = 1 << 6; /* default: 6 */ 2222 opt = 1 << 6; /* default: 6 */
2223 /* Map 1..3 to 4 */ 2223 opt = ffs(opt >> 4); /* Maps -1..-4 to [0], -5 to [1] ... -9 to [5] */
2224 if (opt & 0x7)
2225 opt |= 1 << 4;
2226 opt = ffs(opt >> 3);
2227 max_chain_length = 1 << gzip_level_config[opt].chain_shift; 2224 max_chain_length = 1 << gzip_level_config[opt].chain_shift;
2228 good_match = gzip_level_config[opt].good; 2225 good_match = gzip_level_config[opt].good;
2229 max_lazy_match = gzip_level_config[opt].lazy2 * 2; 2226 max_lazy_match = gzip_level_config[opt].lazy2 * 2;
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index e674e9a0d..48dc6e3d9 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -362,10 +362,9 @@ IF_FEATURE_IP_RULE(ARG_table,)
362 req.r.rtm_scope = RT_SCOPE_NOWHERE; 362 req.r.rtm_scope = RT_SCOPE_NOWHERE;
363 363
364 if (cmd != RTM_DELROUTE) { 364 if (cmd != RTM_DELROUTE) {
365 req.r.rtm_scope = RT_SCOPE_UNIVERSE;
365 if (RTPROT_BOOT != 0) 366 if (RTPROT_BOOT != 0)
366 req.r.rtm_protocol = RTPROT_BOOT; 367 req.r.rtm_protocol = RTPROT_BOOT;
367 if (RT_SCOPE_UNIVERSE != 0)
368 req.r.rtm_scope = RT_SCOPE_UNIVERSE;
369 if (RTN_UNICAST != 0) 368 if (RTN_UNICAST != 0)
370 req.r.rtm_type = RTN_UNICAST; 369 req.r.rtm_type = RTN_UNICAST;
371 } 370 }
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 98158a304..1a3367be2 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -2051,6 +2051,13 @@ recv_and_process_client_pkt(void /*int fd*/)
2051 goto bail; 2051 goto bail;
2052 } 2052 }
2053 2053
2054 /* Respond only to client and symmetric active packets */
2055 if ((msg.m_status & MODE_MASK) != MODE_CLIENT
2056 && (msg.m_status & MODE_MASK) != MODE_SYM_ACT
2057 ) {
2058 goto bail;
2059 }
2060
2054 query_status = msg.m_status; 2061 query_status = msg.m_status;
2055 query_xmttime = msg.m_xmttime; 2062 query_xmttime = msg.m_xmttime;
2056 2063
diff --git a/shell/hush.c b/shell/hush.c
index eabe83ac6..dfbbb4122 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -1477,19 +1477,50 @@ static sighandler_t install_sighandler(int sig, sighandler_t handler)
1477 return old_sa.sa_handler; 1477 return old_sa.sa_handler;
1478} 1478}
1479 1479
1480static void hush_exit(int exitcode) NORETURN;
1481static void fflush_and__exit(void) NORETURN;
1482static void restore_ttypgrp_and__exit(void) NORETURN;
1483
1484static void restore_ttypgrp_and__exit(void)
1485{
1486 /* xfunc has failed! die die die */
1487 /* no EXIT traps, this is an escape hatch! */
1488 G.exiting = 1;
1489 hush_exit(xfunc_error_retval);
1490}
1491
1492/* Needed only on some libc:
1493 * It was observed that on exit(), fgetc'ed buffered data
1494 * gets "unwound" via lseek(fd, -NUM, SEEK_CUR).
1495 * With the net effect that even after fork(), not vfork(),
1496 * exit() in NOEXECed applet in "sh SCRIPT":
1497 * noexec_applet_here
1498 * echo END_OF_SCRIPT
1499 * lseeks fd in input FILE object from EOF to "e" in "echo END_OF_SCRIPT".
1500 * This makes "echo END_OF_SCRIPT" executed twice.
1501 * Similar problems can be seen with die_if_script() -> xfunc_die()
1502 * and in `cmd` handling.
1503 * If set as die_func(), this makes xfunc_die() exit via _exit(), not exit():
1504 */
1505static void fflush_and__exit(void)
1506{
1507 fflush_all();
1508 _exit(xfunc_error_retval);
1509}
1510
1480#if ENABLE_HUSH_JOB 1511#if ENABLE_HUSH_JOB
1481 1512
1482static void xfunc_has_died(void);
1483/* After [v]fork, in child: do not restore tty pgrp on xfunc death */ 1513/* After [v]fork, in child: do not restore tty pgrp on xfunc death */
1484# define disable_restore_tty_pgrp_on_exit() (die_func = NULL) 1514# define disable_restore_tty_pgrp_on_exit() (die_func = fflush_and__exit)
1485/* After [v]fork, in parent: restore tty pgrp on xfunc death */ 1515/* After [v]fork, in parent: restore tty pgrp on xfunc death */
1486# define enable_restore_tty_pgrp_on_exit() (die_func = xfunc_has_died) 1516# define enable_restore_tty_pgrp_on_exit() (die_func = restore_ttypgrp_and__exit)
1487 1517
1488/* Restores tty foreground process group, and exits. 1518/* Restores tty foreground process group, and exits.
1489 * May be called as signal handler for fatal signal 1519 * May be called as signal handler for fatal signal
1490 * (will resend signal to itself, producing correct exit state) 1520 * (will resend signal to itself, producing correct exit state)
1491 * or called directly with -EXITCODE. 1521 * or called directly with -EXITCODE.
1492 * We also call it if xfunc is exiting. */ 1522 * We also call it if xfunc is exiting.
1523 */
1493static void sigexit(int sig) NORETURN; 1524static void sigexit(int sig) NORETURN;
1494static void sigexit(int sig) 1525static void sigexit(int sig)
1495{ 1526{
@@ -1544,7 +1575,6 @@ static sighandler_t pick_sighandler(unsigned sig)
1544} 1575}
1545 1576
1546/* Restores tty foreground process group, and exits. */ 1577/* Restores tty foreground process group, and exits. */
1547static void hush_exit(int exitcode) NORETURN;
1548static void hush_exit(int exitcode) 1578static void hush_exit(int exitcode)
1549{ 1579{
1550#if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT 1580#if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT
@@ -1580,23 +1610,14 @@ static void hush_exit(int exitcode)
1580 } 1610 }
1581#endif 1611#endif
1582 1612
1583#if ENABLE_HUSH_JOB
1584 fflush_all(); 1613 fflush_all();
1614#if ENABLE_HUSH_JOB
1585 sigexit(- (exitcode & 0xff)); 1615 sigexit(- (exitcode & 0xff));
1586#else 1616#else
1587 exit(exitcode); 1617 _exit(exitcode);
1588#endif 1618#endif
1589} 1619}
1590 1620
1591static void xfunc_has_died(void) NORETURN;
1592static void xfunc_has_died(void)
1593{
1594 /* xfunc has failed! die die die */
1595 /* no EXIT traps, this is an escape hatch! */
1596 G.exiting = 1;
1597 hush_exit(xfunc_error_retval);
1598}
1599
1600 1621
1601//TODO: return a mask of ALL handled sigs? 1622//TODO: return a mask of ALL handled sigs?
1602static int check_and_run_traps(void) 1623static int check_and_run_traps(void)
@@ -1766,6 +1787,7 @@ static int set_local_var(char *str, int flg_export, int local_lvl, int flg_read_
1766{ 1787{
1767 struct variable **var_pp; 1788 struct variable **var_pp;
1768 struct variable *cur; 1789 struct variable *cur;
1790 char *free_me = NULL;
1769 char *eq_sign; 1791 char *eq_sign;
1770 int name_len; 1792 int name_len;
1771 1793
@@ -1782,6 +1804,7 @@ static int set_local_var(char *str, int flg_export, int local_lvl, int flg_read_
1782 var_pp = &cur->next; 1804 var_pp = &cur->next;
1783 continue; 1805 continue;
1784 } 1806 }
1807
1785 /* We found an existing var with this name */ 1808 /* We found an existing var with this name */
1786 if (cur->flg_read_only) { 1809 if (cur->flg_read_only) {
1787#if !BB_MMU 1810#if !BB_MMU
@@ -1830,12 +1853,17 @@ static int set_local_var(char *str, int flg_export, int local_lvl, int flg_read_
1830 strcpy(cur->varstr, str); 1853 strcpy(cur->varstr, str);
1831 goto free_and_exp; 1854 goto free_and_exp;
1832 } 1855 }
1833 } else { 1856 /* Can't reuse */
1834 /* max_len == 0 signifies "malloced" var, which we can 1857 cur->max_len = 0;
1835 * (and has to) free */ 1858 goto set_str_and_exp;
1836 free(cur->varstr); 1859 }
1837 } 1860 /* max_len == 0 signifies "malloced" var, which we can
1838 cur->max_len = 0; 1861 * (and have to) free. But we can't free(cur->varstr) here:
1862 * if cur->flg_export is 1, it is in the environment.
1863 * We should either unsetenv+free, or wait until putenv,
1864 * then putenv(new)+free(old).
1865 */
1866 free_me = cur->varstr;
1839 goto set_str_and_exp; 1867 goto set_str_and_exp;
1840 } 1868 }
1841 1869
@@ -1862,10 +1890,15 @@ static int set_local_var(char *str, int flg_export, int local_lvl, int flg_read_
1862 cur->flg_export = 0; 1890 cur->flg_export = 0;
1863 /* unsetenv was already done */ 1891 /* unsetenv was already done */
1864 } else { 1892 } else {
1893 int i;
1865 debug_printf_env("%s: putenv '%s'\n", __func__, cur->varstr); 1894 debug_printf_env("%s: putenv '%s'\n", __func__, cur->varstr);
1866 return putenv(cur->varstr); 1895 i = putenv(cur->varstr);
1896 /* only now we can free old exported malloced string */
1897 free(free_me);
1898 return i;
1867 } 1899 }
1868 } 1900 }
1901 free(free_me);
1869 return 0; 1902 return 0;
1870} 1903}
1871 1904
@@ -5913,7 +5946,8 @@ static FILE *generate_stream_from_string(const char *s, pid_t *pid_p)
5913 ) { 5946 ) {
5914 static const char *const argv[] = { NULL, NULL }; 5947 static const char *const argv[] = { NULL, NULL };
5915 builtin_trap((char**)argv); 5948 builtin_trap((char**)argv);
5916 exit(0); /* not _exit() - we need to fflush */ 5949 fflush_all(); /* important */
5950 _exit(0);
5917 } 5951 }
5918# if BB_MMU 5952# if BB_MMU
5919 reset_traps_to_defaults(); 5953 reset_traps_to_defaults();
@@ -6466,7 +6500,8 @@ static void dump_cmd_in_x_mode(char **argv)
6466 * Never returns. 6500 * Never returns.
6467 * Don't exit() here. If you don't exec, use _exit instead. 6501 * Don't exit() here. If you don't exec, use _exit instead.
6468 * The at_exit handlers apparently confuse the calling process, 6502 * The at_exit handlers apparently confuse the calling process,
6469 * in particular stdin handling. Not sure why? -- because of vfork! (vda) */ 6503 * in particular stdin handling. Not sure why? -- because of vfork! (vda)
6504 */
6470static void pseudo_exec_argv(nommu_save_t *nommu_save, 6505static void pseudo_exec_argv(nommu_save_t *nommu_save,
6471 char **argv, int assignment_cnt, 6506 char **argv, int assignment_cnt,
6472 char **argv_expanded) NORETURN; 6507 char **argv_expanded) NORETURN;
@@ -7787,6 +7822,7 @@ int hush_main(int argc, char **argv)
7787 INIT_G(); 7822 INIT_G();
7788 if (EXIT_SUCCESS != 0) /* if EXIT_SUCCESS == 0, it is already done */ 7823 if (EXIT_SUCCESS != 0) /* if EXIT_SUCCESS == 0, it is already done */
7789 G.last_exitcode = EXIT_SUCCESS; 7824 G.last_exitcode = EXIT_SUCCESS;
7825
7790#if ENABLE_HUSH_FAST 7826#if ENABLE_HUSH_FAST
7791 G.count_SIGCHLD++; /* ensure it is != G.handled_SIGCHLD */ 7827 G.count_SIGCHLD++; /* ensure it is != G.handled_SIGCHLD */
7792#endif 7828#endif
@@ -7876,7 +7912,7 @@ int hush_main(int argc, char **argv)
7876 /* Initialize some more globals to non-zero values */ 7912 /* Initialize some more globals to non-zero values */
7877 cmdedit_update_prompt(); 7913 cmdedit_update_prompt();
7878 7914
7879 die_func = xfunc_has_died; 7915 die_func = restore_ttypgrp_and__exit;
7880 7916
7881 /* Shell is non-interactive at first. We need to call 7917 /* Shell is non-interactive at first. We need to call
7882 * install_special_sighandlers() if we are going to execute "sh <script>", 7918 * install_special_sighandlers() if we are going to execute "sh <script>",