Add macosx fix from #1407
[openwrt.git] / package / busybox / patches / 170-tar_segfault.patch
1 --- busybox.old/archival/tar.c  2007/02/03 17:28:39     17740
2 +++ busybox.dev/archival/tar.c  2007/02/04 21:30:35     17772
3 @@ -761,7 +761,9 @@
4         const char *tar_filename = "-";
5         unsigned opt;
6         int verboseFlag = 0;
7 +#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
8         llist_t *excludes = NULL;
9 +#endif
10  
11         /* Initialise default values */
12         tar_handle = init_handle();
13 @@ -774,7 +776,9 @@
14                 "tt:vv:" // count -t,-v
15                 "?:" // bail out with usage instead of error return
16                 "X::T::" // cumulative lists
17 +#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
18                 "\xff::" // cumulative lists for --exclude
19 +#endif
20                 USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
21                 USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
22                 SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
23 @@ -789,14 +793,15 @@
24                 USE_FEATURE_TAR_FROM(    "T:X:")
25                 USE_FEATURE_TAR_GZIP(    "z"   )
26                 USE_FEATURE_TAR_COMPRESS("Z"   )
27 -               ,
28 -               &base_dir, // -C dir
29 -               &tar_filename, // -f filename
30 -               USE_FEATURE_TAR_FROM(&(tar_handle->accept),) // T
31 -               USE_FEATURE_TAR_FROM(&(tar_handle->reject),) // X
32 -               USE_FEATURE_TAR_FROM(&excludes            ,) // --exclude
33 -               &verboseFlag, // combined count for -t and -v
34 -               &verboseFlag // combined count for -t and -v
35 +               , &base_dir // -C dir
36 +               , &tar_filename // -f filename
37 +               USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
38 +               USE_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X
39 +#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
40 +               , &excludes // --exclude
41 +#endif
42 +               , &verboseFlag // combined count for -t and -v
43 +               , &verboseFlag // combined count for -t and -v
44                 );
45  
46         if (verboseFlag) tar_handle->action_header = header_verbose_list;
47 @@ -829,17 +834,19 @@
48         if (opt & OPT_COMPRESS)
49                 get_header_ptr = get_header_tar_Z;
50  
51 -       if (ENABLE_FEATURE_TAR_FROM) {
52 -               tar_handle->reject = append_file_list_to_list(tar_handle->reject);
53 -               /* Append excludes to reject */
54 -               while (excludes) {
55 -                       llist_t *temp = excludes->link;
56 -                       excludes->link = tar_handle->reject;
57 -                       tar_handle->reject = excludes;
58 -                       excludes = temp;
59 -               }
60 -               tar_handle->accept = append_file_list_to_list(tar_handle->accept);
61 +#if ENABLE_FEATURE_TAR_FROM
62 +       tar_handle->reject = append_file_list_to_list(tar_handle->reject);
63 +#if ENABLE_FEATURE_TAR_LONG_OPTIONS
64 +       /* Append excludes to reject */
65 +       while (excludes) {
66 +               llist_t *next = excludes->link;
67 +               excludes->link = tar_handle->reject;
68 +               tar_handle->reject = excludes;
69 +               excludes = next;
70         }
71 +#endif
72 +       tar_handle->accept = append_file_list_to_list(tar_handle->accept);
73 +#endif
74  
75         /* Check if we are reading from stdin */
76         if (argv[optind] && *argv[optind] == '-') {
77