Changeset 12069


Ignore:
Timestamp:
05/09/09 11:18:51 (4 years ago)
Author:
BrainSlayer
Message:

update to 1.13.4

Location:
src/router/busybox
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/router/busybox/Makefile

    r11754 r12069  
    11VERSION = 1 
    22PATCHLEVEL = 13 
    3 SUBLEVEL = 3 
     3SUBLEVEL = 4 
    44EXTRAVERSION = 
    55NAME = Unnamed 
  • src/router/busybox/archival/libunarchive/get_header_tar.c

    r10463 r12069  
    9292 again_after_align: 
    9393 
    94 #if ENABLE_DESKTOP 
     94#if ENABLE_DESKTOP || ENABLE_FEATURE_TAR_AUTODETECT 
    9595        /* to prevent misdetection of bz2 sig */ 
    9696        *(uint32_t*)(&tar) = 0; 
     
    143143                char FAST_FUNC (*get_header_ptr)(archive_handle_t *); 
    144144 
    145  USE_DESKTOP(autodetect:) 
     145 autodetect: 
    146146                /* tar gz/bz autodetect: check for gz/bz2 magic. 
    147147                 * If we see the magic, and it is the very first block, 
  • src/router/busybox/archival/tar.c

    r11754 r12069  
    935935                        tar_handle->seek = seek_by_read; 
    936936                } else { 
    937                         if (ENABLE_FEATURE_TAR_AUTODETECT && flags == O_RDONLY) { 
    938                                 get_header_ptr = get_header_tar; 
     937                        if (ENABLE_FEATURE_TAR_AUTODETECT 
     938                         && get_header_ptr == get_header_tar 
     939                         && flags == O_RDONLY 
     940                        ) { 
    939941                                tar_handle->src_fd = open_zipped(tar_filename); 
    940942                                if (tar_handle->src_fd < 0) 
  • src/router/busybox/coreutils/tail.c

    r10463 r12069  
    105105         && isdigit(argv[1][1]) 
    106106        ) { 
    107                 count = eat_num(&argv[1][1]); 
     107                count = eat_num(argv[1]); 
    108108                argv++; 
    109109                argc--; 
  • src/router/busybox/shell/ash.c

    r11061 r12069  
    3131 
    3232/* 
    33  * The follow should be set to reflect the type of system you have: 
     33 * The following should be set to reflect the type of system you have: 
    3434 *      JOBS -> 1 if you have Berkeley job control, 0 otherwise. 
    3535 *      define SYSV if you are running under System V. 
     
    4141 */ 
    4242#define DEBUG 0 
     43/* Tweak debug output verbosity here */ 
     44#define DEBUG_TIME 0 
     45#define DEBUG_PID 1 
     46#define DEBUG_SIG 1 
     47 
    4348#define PROFILE 0 
    4449 
     
    4853 
    4954#if DEBUG 
    50 #ifndef _GNU_SOURCE 
    51 #define _GNU_SOURCE 
    52 #endif 
     55# ifndef _GNU_SOURCE 
     56#  define _GNU_SOURCE 
     57# endif 
    5358#endif 
    5459 
     
    5863#include <fnmatch.h> 
    5964#if JOBS || ENABLE_ASH_READ_NCHARS 
    60 #include <termios.h> 
     65# include <termios.h> 
    6166#endif 
    6267 
    6368#ifndef PIPE_BUF 
    64 #define PIPE_BUF 4096           /* amount of buffering in a pipe */ 
     69# define PIPE_BUF 4096           /* amount of buffering in a pipe */ 
    6570#endif 
    6671 
    6772#if defined(__uClinux__) 
    68 #error "Do not even bother, ash will not run on uClinux" 
     73# error "Do not even bother, ash will not run on uClinux" 
    6974#endif 
    7075 
     
    7580#define ATABSIZE 39 
    7681#define CMDTABLESIZE 31         /* should be prime */ 
    77  
    78  
    79 /* ============ Misc helpers */ 
    80  
    81 #define xbarrier() do { __asm__ __volatile__ ("": : :"memory"); } while (0) 
    82  
    83 /* C99 say: "char" declaration may be signed or unsigned default */ 
    84 #define signed_char2int(sc) ((int)((signed char)sc)) 
    8582 
    8683 
     
    246243 
    247244 
     245/* ============ DEBUG */ 
     246#if DEBUG 
     247static void trace_printf(const char *fmt, ...); 
     248static void trace_vprintf(const char *fmt, va_list va); 
     249# define TRACE(param)    trace_printf param 
     250# define TRACEV(param)   trace_vprintf param 
     251# define close(f) do { \ 
     252        int dfd = (f); \ 
     253        if (close(dfd) < 0) \ 
     254                bb_error_msg("bug on %d: closing %d(%x)", \ 
     255                        __LINE__, dfd, dfd); \ 
     256} while (0) 
     257#else 
     258# define TRACE(param) 
     259# define TRACEV(param) 
     260#endif 
     261 
     262 
    248263/* ============ Utility functions */ 
     264#define xbarrier() do { __asm__ __volatile__ ("": : :"memory"); } while (0) 
     265 
     266/* C99 say: "char" declaration may be signed or unsigned by default */ 
     267#define signed_char2int(sc) ((int)(signed char)(sc)) 
     268 
    249269static int isdigit_str9(const char *str) 
    250270{ 
     
    285305        longjmp(exception_handler->loc, 1); 
    286306} 
     307#if DEBUG 
     308#define raise_exception(e) do { \ 
     309        TRACE(("raising exception %d on line %d\n", (e), __LINE__)); \ 
     310        raise_exception(e); \ 
     311} while (0) 
     312#endif 
    287313 
    288314/* 
     
    317343        /* NOTREACHED */ 
    318344} 
     345#if DEBUG 
     346#define raise_interrupt() do { \ 
     347        TRACE(("raising interrupt on line %d\n", __LINE__)); \ 
     348        raise_interrupt(); \ 
     349} while (0) 
     350#endif 
    319351 
    320352#if ENABLE_ASH_OPTIMIZE_FOR_SIZE 
     
    335367} 
    336368#define FORCE_INT_ON force_int_on() 
    337 #else 
     369 
     370#else /* !ASH_OPTIMIZE_FOR_SIZE */ 
     371 
    338372#define INT_ON do { \ 
    339373        xbarrier(); \ 
     
    347381                raise_interrupt(); \ 
    348382} while (0) 
    349 #endif /* ASH_OPTIMIZE_FOR_SIZE */ 
     383#endif /* !ASH_OPTIMIZE_FOR_SIZE */ 
    350384 
    351385#define SAVE_INT(v) ((v) = suppressint) 
     
    377411{ 
    378412        gotsig[signo - 1] = 1; 
    379         pendingsig = signo; 
    380413 
    381414        if (/* exsig || */ (signo == SIGINT && !trap[SIGINT])) { 
     
    385418                } 
    386419                intpending = 1; 
     420        } else { 
     421                pendingsig = signo; 
    387422        } 
    388423} 
     
    685720        if (debug != 1) 
    686721                return; 
     722        if (DEBUG_TIME) 
     723                fprintf(tracefile, "%u ", (int) time(NULL)); 
     724        if (DEBUG_PID) 
     725                fprintf(tracefile, "[%u] ", (int) getpid()); 
     726        if (DEBUG_SIG) 
     727                fprintf(tracefile, "pending s:%d i:%d(supp:%d) ", pendingsig, intpending, suppressint); 
    687728        va_start(va, fmt); 
    688729        vfprintf(tracefile, fmt, va); 
     
    695736        if (debug != 1) 
    696737                return; 
     738        if (DEBUG_TIME) 
     739                fprintf(tracefile, "%u ", (int) time(NULL)); 
     740        if (DEBUG_PID) 
     741                fprintf(tracefile, "[%u] ", (int) getpid()); 
     742        if (DEBUG_SIG) 
     743                fprintf(tracefile, "pending s:%d i:%d(supp:%d) ", pendingsig, intpending, suppressint); 
    697744        vfprintf(tracefile, fmt, va); 
    698745} 
     
    9981045        shtree(n, 1, NULL, stdout); 
    9991046} 
    1000  
    1001 #define TRACE(param)    trace_printf param 
    1002 #define TRACEV(param)   trace_vprintf param 
    1003  
    1004 #else 
    1005  
    1006 #define TRACE(param) 
    1007 #define TRACEV(param) 
    10081047 
    10091048#endif /* DEBUG */ 
     
    37803819        pid = waitpid(-1, &status, 
    37813820                        (doing_jobctl ? (wait_flags | WUNTRACED) : wait_flags)); 
    3782         TRACE(("wait returns pid=%d, status=0x%x\n", pid, status)); 
     3821        TRACE(("wait returns pid=%d, status=0x%x, errno=%d(%s)\n", pid, status, errno, strerror(errno))); 
    37833822 
    37843823        if (pid <= 0) { 
     
    50325071                        /* NTOFD/NFROMFD: copy redir->ndup.dupfd to fd */ 
    50335072                        if (redir->ndup.dupfd < 0) { /* "fd>&-" */ 
    5034                                 close(fd); 
     5073                                /* Don't want to trigger debugging */ 
     5074                                if (fd != -1) 
     5075                                        close(fd); 
    50355076                        } else { 
    50365077                                copyfd(redir->ndup.dupfd, fd | COPYFD_EXACT); 
     
    50855126                                copyfd(copy, fd | COPYFD_EXACT); 
    50865127                        } 
    5087                         close(copy); 
     5128                        close(copy & ~COPYFD_RESTORE); 
    50885129                } 
    50895130        } 
     
    78727913        xbarrier(); 
    78737914 
     7915        TRACE(("dotrap entered\n")); 
    78747916        for (i = 1, q = gotsig; i < NSIG; i++, q++) { 
    78757917                if (!*q) 
    78767918                        continue; 
     7919 
     7920                p = trap[i]; 
     7921                /* non-trapped SIGINT is handled separately by raise_interrupt, 
     7922                 * don't upset it by resetting gotsig[SIGINT-1] */ 
     7923                if (i == SIGINT && !p) 
     7924                        continue; 
     7925 
     7926                TRACE(("sig %d is active, will run handler '%s'\n", i, p)); 
    78777927                *q = '\0'; 
    7878  
    7879                 p = trap[i]; 
    78807928                if (!p) 
    78817929                        continue; 
    78827930                skip = evalstring(p, SKIPEVAL); 
    78837931                exitstatus = savestatus; 
    7884                 if (skip) 
     7932                if (skip) { 
     7933                        TRACE(("dotrap returns %d\n", skip)); 
    78857934                        return skip; 
    7886         } 
    7887  
     7935                } 
     7936        } 
     7937 
     7938        TRACE(("dotrap returns 0\n")); 
    78887939        return 0; 
    78897940} 
     
    79077958evaltree(union node *n, int flags) 
    79087959{ 
    7909  
    79107960        struct jmploc *volatile savehandler = exception_handler; 
    79117961        struct jmploc jmploc; 
     
    79137963        void (*evalfn)(union node *, int); 
    79147964        int status; 
     7965        int int_level; 
     7966 
     7967        SAVE_INT(int_level); 
    79157968 
    79167969        if (n == NULL) { 
     
    79187971                goto out1; 
    79197972        } 
    7920         TRACE(("pid %d, evaltree(%p: %d, %d) called\n", 
    7921                         getpid(), n, n->type, flags)); 
     7973        TRACE(("evaltree(%p: %d, %d) called\n", n, n->type, flags)); 
    79227974 
    79237975        exception_handler = &jmploc; 
     
    79267978                if (err) { 
    79277979                        /* if it was a signal, check for trap handlers */ 
    7928                         if (exception == EXSIG) 
     7980                        if (exception == EXSIG) { 
     7981                                TRACE(("exception %d (EXSIG) in evaltree, err=%d\n", exception, err)); 
    79297982                                goto out; 
     7983                        } 
    79307984                        /* continue on the way out */ 
     7985                        TRACE(("exception %d in evaltree, propagating err=%d\n", exception, err)); 
    79317986                        exception_handler = savehandler; 
    79327987                        longjmp(exception_handler->loc, err); 
     
    80118066                        n = n->nif.ifpart; 
    80128067                        goto evaln; 
    8013                 } else if (n->nif.elsepart) { 
     8068                } 
     8069                if (n->nif.elsepart) { 
    80148070                        n = n->nif.elsepart; 
    80158071                        goto evaln; 
     
    80378093                raise_exception(EXEXIT); 
    80388094        } 
     8095 
     8096        RESTORE_INT(int_level); 
     8097        TRACE(("leaving evaltree (no interrupts)\n")); 
    80398098} 
    80408099 
     
    82828341                        close(prevfd); 
    82838342                prevfd = pip[0]; 
    8284                 close(pip[1]); 
     8343                /* Don't want to trigger debugging */ 
     8344                if (pip[1] != -1) 
     8345                        close(pip[1]); 
    82858346        } 
    82868347        if (n->npipe.pipe_backgnd == 0) { 
     
    89148975                                exitstatus = waitforjob(jp); 
    89158976                                INT_ON; 
     8977                                TRACE(("forked child exited with %d\n", exitstatus)); 
    89168978                                break; 
    89178979                        } 
     
    1239212454 
    1239312455        status = 0; 
    12394         startword = 1; 
     12456        startword = 2; 
    1239512457        backslash = 0; 
    1239612458#if ENABLE_ASH_READ_TIMEOUT 
     
    1240012462        STARTSTACKSTR(p); 
    1240112463        do { 
     12464                const char *is_ifs; 
     12465 
    1240212466#if ENABLE_ASH_READ_TIMEOUT 
    1240312467                if (end_ms) { 
     
    1242912493                } 
    1243012494                if (!rflag && c == '\\') { 
    12431                         backslash++; 
     12495                        backslash = 1; 
    1243212496                        continue; 
    1243312497                } 
    1243412498                if (c == '\n') 
    1243512499                        break; 
    12436                 if (startword && *ifs == ' ' && strchr(ifs, c)) { 
     12500                is_ifs = strchr(ifs, c); 
     12501                if (startword && is_ifs) { 
     12502                        if (isspace(c)) 
     12503                                continue; 
     12504                        /* non-space ifs char */ 
     12505                        startword--; 
     12506                        if (startword == 1) /* first one? */ 
     12507                                continue; 
     12508                } 
     12509                startword = 0; 
     12510                if (ap[1] != NULL && is_ifs) { 
     12511                        const char *beg; 
     12512                        STACKSTRNUL(p); 
     12513                        beg = stackblock(); 
     12514                        setvar(*ap, beg, 0); 
     12515                        ap++; 
     12516                        /* can we skip one non-space ifs? (2: yes) */ 
     12517                        startword = isspace(c) ? 2 : 1; 
     12518                        STARTSTACKSTR(p); 
    1243712519                        continue; 
    1243812520                } 
    12439                 startword = 0; 
    12440                 if (ap[1] != NULL && strchr(ifs, c) != NULL) { 
    12441                         STACKSTRNUL(p); 
    12442                         setvar(*ap, stackblock(), 0); 
    12443                         ap++; 
    12444                         startword = 1; 
    12445                         STARTSTACKSTR(p); 
    12446                 } else { 
    1244712521 put: 
    12448                         STPUTC(c, p); 
    12449                 } 
     12522                STPUTC(c, p); 
    1245012523        } 
    1245112524/* end of do {} while: */ 
     
    1246112534 
    1246212535        STACKSTRNUL(p); 
    12463         /* Remove trailing blanks */ 
    12464         while ((char *)stackblock() <= --p && strchr(ifs, *p) != NULL) 
     12536        /* Remove trailing space ifs chars */ 
     12537        while ((char *)stackblock() <= --p && isspace(*p) && strchr(ifs, *p) != NULL) 
    1246512538                *p = '\0'; 
    1246612539        setvar(*ap, stackblock(), 0); 
     
    1364113714#if DEBUG 
    1364213715        opentrace(); 
    13643         trace_puts("Shell args: "); 
     13716        TRACE(("Shell args: ")); 
    1364413717        trace_puts_args(argv); 
    1364513718#endif 
     
    1369313766 state3: 
    1369413767        state = 4; 
    13695         if (minusc) 
     13768        if (minusc) { 
     13769                /* evalstring pushes parsefile stack. 
     13770                 * Ensure we don't falsely claim that 0 (stdin) 
     13771                 * is one of stacked source fds */ 
     13772                if (!sflag) 
     13773                        g_parsefile->fd = -1; 
    1369613774                evalstring(minusc, 0); 
     13775        } 
    1369713776 
    1369813777        if (sflag || minusc == NULL) { 
     
    1372013799        /* NOTREACHED */ 
    1372113800} 
    13722  
    13723 #if DEBUG 
    13724 const char *applet_name = "debug stuff usage"; 
    13725 int main(int argc, char **argv) 
    13726 { 
    13727         return ash_main(argc, argv); 
    13728 } 
    13729 #endif 
    1373013801 
    1373113802 
  • src/router/busybox/shell/hush.c

    r11061 r12069  
    459459        /* these three support $?, $#, and $1 */ 
    460460        smalluint last_return_code; 
     461        /* is global_argv and global_argv[1..n] malloced? (note: not [0]) */ 
     462        smalluint global_args_malloced; 
     463        /* how many non-NULL argv's we have. NB: $# + 1 */ 
     464        int global_argc; 
    461465        char **global_argv; 
    462         int global_argc; 
    463466#if ENABLE_HUSH_LOOPS 
    464467        unsigned depth_break_continue; 
     
    634637} 
    635638 
    636 static char **add_strings_to_strings(char **strings, char **add) 
     639static char **add_strings_to_strings(char **strings, char **add, int need_to_dup) 
    637640{ 
    638641        int i; 
     
    659662        i = count2; 
    660663        while (--i >= 0) 
    661                 v[count1 + i] = add[i]; 
     664                v[count1 + i] = (need_to_dup ? xstrdup(add[i]) : add[i]); 
    662665        return v; 
    663666} 
     
    668671        v[0] = add; 
    669672        v[1] = NULL; 
    670         return add_strings_to_strings(strings, v); 
     673        return add_strings_to_strings(strings, v, /*dup:*/ 0); 
    671674} 
    672675 
     
    12141217static int o_save_ptr(o_string *o, int n) 
    12151218{ 
    1216         if (o->o_glob) 
    1217                 return o_glob(o, n); /* o_save_ptr_helper is inside */ 
     1219        if (o->o_glob) { /* if globbing is requested */ 
     1220                /* If o->has_empty_slot, list[n] was already globbed 
     1221                 * (if it was requested back then when it was filled) 
     1222                 * so don't do that again! */ 
     1223                if (!o->has_empty_slot) 
     1224                        return o_glob(o, n); /* o_save_ptr_helper is inside */ 
     1225        } 
    12181226        return o_save_ptr_helper(o, n); 
    12191227} 
     
    42804288                case 'c': 
    42814289                        G.global_argv = argv + optind; 
     4290                        if (!argv[optind]) { 
     4291                                /* -c 'script' (no params): prevent empty $0 */ 
     4292                                *--G.global_argv = argv[0]; 
     4293                                optind--; 
     4294                        } /* else -c 'script' PAR0 PAR1: $0 is PAR0 */ 
    42824295                        G.global_argc = argc - optind; 
    42834296                        opt = parse_and_run_string(optarg, 0 /* parse_flag */); 
     
    46404653} 
    46414654 
    4642 /* built-in 'set [VAR=value]' handler */ 
     4655/* built-in 'set' handler 
     4656 * SUSv3 says: 
     4657 * set [-abCefmnuvx] [-h] [-o option] [argument...] 
     4658 * set [+abCefmnuvx] [+h] [+o option] [argument...] 
     4659 * set -- [argument...] 
     4660 * set -o 
     4661 * set +o 
     4662 * Implementations shall support the options in both their hyphen and 
     4663 * plus-sign forms. These options can also be specified as options to sh. 
     4664 * Examples: 
     4665 * Write out all variables and their values: set 
     4666 * Set $1, $2, and $3 and set "$#" to 3: set c a b 
     4667 * Turn on the -x and -v options: set -xv 
     4668 * Unset all positional parameters: set -- 
     4669 * Set $1 to the value of x, even if it begins with '-' or '+': set -- "$x" 
     4670 * Set the positional parameters to the expansion of x, even if x expands 
     4671 * with a leading '-' or '+': set -- $x 
     4672 * 
     4673 * So far, we only support "set -- [argument...]" by ignoring all options 
     4674 * (also, "-o option" will be mishandled by taking "option" as parameter #1). 
     4675 */ 
    46434676static int builtin_set(char **argv) 
    46444677{ 
    4645         char *temp = argv[1]; 
    46464678        struct variable *e; 
    4647  
    4648         if (temp == NULL) 
     4679        char **pp; 
     4680        char *arg = *++argv; 
     4681 
     4682        if (arg == NULL) { 
    46494683                for (e = G.top_var; e; e = e->next) 
    46504684                        puts(e->varstr); 
    4651         else 
    4652                 set_local_var(xstrdup(temp), 0); 
     4685        } else { 
     4686                /* NB: G.global_argv[0] ($0) is never freed/changed */ 
     4687 
     4688                if (G.global_args_malloced) { 
     4689                        pp = G.global_argv; 
     4690                        while (*++pp) 
     4691                                free(*pp); 
     4692                        G.global_argv[1] = NULL; 
     4693                } else { 
     4694                        G.global_args_malloced = 1; 
     4695                        pp = xzalloc(sizeof(pp[0]) * 2); 
     4696                        pp[0] = G.global_argv[0]; /* retain $0 */ 
     4697                        G.global_argv = pp; 
     4698                } 
     4699                do  { 
     4700                        if (arg[0] == '+') 
     4701                                continue; 
     4702                        if (arg[0] != '-') 
     4703                                break; 
     4704                        if (arg[1] == '-' && arg[2] == '\0') { 
     4705                                argv++; 
     4706                                break; 
     4707                        } 
     4708                } while ((arg = *++argv) != NULL); 
     4709                /* Now argv[0] is 1st argument */ 
     4710 
     4711                /* This realloc's G.global_argv */ 
     4712                G.global_argv = pp = add_strings_to_strings(G.global_argv, argv, /*dup:*/ 1); 
     4713                G.global_argc = 1; 
     4714                while (*++pp) 
     4715                        G.global_argc++; 
     4716        } 
    46534717 
    46544718        return EXIT_SUCCESS; 
     
    46624726        } 
    46634727        if (n >= 0 && n < G.global_argc) { 
    4664                 G.global_argv[n] = G.global_argv[0]; 
     4728                if (G.global_args_malloced) { 
     4729                        int m = 1; 
     4730                        while (m <= n) 
     4731                                free(G.global_argv[m++]); 
     4732                } 
    46654733                G.global_argc -= n; 
    4666                 G.global_argv += n; 
     4734                memmove(&G.global_argv[1], &G.global_argv[n+1], 
     4735                                G.global_argc * sizeof(G.global_argv[0])); 
    46674736                return EXIT_SUCCESS; 
    46684737        } 
  • src/router/busybox/shell/hush_test/hush-parsing/starquoted2.right

    r10463 r12069  
    11Should be printed 
    22Should be printed 
     3Empty: 
  • src/router/busybox/shell/hush_test/hush-parsing/starquoted2.tests

    r10463 r12069  
    1313for a in """$@"''"$@"''; do echo Should not be printed; done 
    1414for a in ""; do echo Should be printed; done 
     15 
     16# Bug 207: "$@" expands to nothing, and we erroneously glob "%s\\n" twice: 
     17printf "Empty:%s\\n" "$@" 
  • src/router/busybox/util-linux/volume_id/get_devname.c

    r11061 r12069  
    224224{ 
    225225        struct uuidCache_s *uc; 
    226         int spec_len = strlen(spec); 
    227226 
    228227        uuidcache_init(); 
    229228        uc = uuidCache; 
    230229        while (uc) { 
    231 // FIXME: empty label ("LABEL=") matches anything??! 
    232                 if (uc->label[0] && strncmp(spec, uc->label, spec_len) == 0) { 
     230                if (uc->label[0] && strcmp(spec, uc->label) == 0) { 
    233231                        return xstrdup(uc->device); 
    234232                } 
Note: See TracChangeset for help on using the changeset viewer.