aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-04-15 14:18:16 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-04-15 14:18:16 +0200
commitb74e490629a75cb8c2cb798f0feadc2eb4dc5471 (patch)
treeff2e333d1939c9d326eea1da4dd26346ecfeb9db
parent58e43a4c40f56a463a475bec5ef915612fc5ed8c (diff)
downloadbusybox-w32-b74e490629a75cb8c2cb798f0feadc2eb4dc5471.tar.gz
busybox-w32-b74e490629a75cb8c2cb798f0feadc2eb4dc5471.tar.bz2
busybox-w32-b74e490629a75cb8c2cb798f0feadc2eb4dc5471.zip
ar: stop using static data
function old new delta static.ar_long_names 4 - -4 static.ar_long_name_size 4 - -4 get_header_ar 546 532 -14 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-22) Total: -22 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--archival/libarchive/get_header_ar.c18
-rw-r--r--include/bb_archive.h4
2 files changed, 11 insertions, 11 deletions
diff --git a/archival/libarchive/get_header_ar.c b/archival/libarchive/get_header_ar.c
index a97970630..adcde46d5 100644
--- a/archival/libarchive/get_header_ar.c
+++ b/archival/libarchive/get_header_ar.c
@@ -34,10 +34,6 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
34 char raw[60]; 34 char raw[60];
35 struct ar_header formatted; 35 struct ar_header formatted;
36 } ar; 36 } ar;
37#if ENABLE_FEATURE_AR_LONG_FILENAMES
38 static char *ar_long_names;
39 static unsigned ar_long_name_size;
40#endif
41 37
42 /* dont use xread as we want to handle the error ourself */ 38 /* dont use xread as we want to handle the error ourself */
43 if (read(archive_handle->src_fd, ar.raw, 60) != 60) { 39 if (read(archive_handle->src_fd, ar.raw, 60) != 60) {
@@ -81,10 +77,10 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
81 * stores long filename for multiple entries, they are stored 77 * stores long filename for multiple entries, they are stored
82 * in static variable long_names for use in future entries 78 * in static variable long_names for use in future entries
83 */ 79 */
84 ar_long_name_size = size; 80 archive_handle->ar__long_name_size = size;
85 free(ar_long_names); 81 free(archive_handle->ar__long_names);
86 ar_long_names = xzalloc(size + 1); 82 archive_handle->ar__long_names = xzalloc(size + 1);
87 xread(archive_handle->src_fd, ar_long_names, size); 83 xread(archive_handle->src_fd, archive_handle->ar__long_names, size);
88 archive_handle->offset += size; 84 archive_handle->offset += size;
89 /* Return next header */ 85 /* Return next header */
90 return get_header_ar(archive_handle); 86 return get_header_ar(archive_handle);
@@ -107,13 +103,13 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
107 unsigned long_offset; 103 unsigned long_offset;
108 104
109 /* The number after the '/' indicates the offset in the ar data section 105 /* The number after the '/' indicates the offset in the ar data section
110 * (saved in ar_long_names) that contains the real filename */ 106 * (saved in ar__long_names) that contains the real filename */
111 long_offset = read_num(&ar.formatted.name[1], 10, 107 long_offset = read_num(&ar.formatted.name[1], 10,
112 sizeof(ar.formatted.name) - 1); 108 sizeof(ar.formatted.name) - 1);
113 if (long_offset >= ar_long_name_size) { 109 if (long_offset >= archive_handle->ar__long_name_size) {
114 bb_error_msg_and_die("can't resolve long filename"); 110 bb_error_msg_and_die("can't resolve long filename");
115 } 111 }
116 typed->name = xstrdup(ar_long_names + long_offset); 112 typed->name = xstrdup(archive_handle->ar__long_names + long_offset);
117 } else 113 } else
118#endif 114#endif
119 { 115 {
diff --git a/include/bb_archive.h b/include/bb_archive.h
index b437f1920..0252488bf 100644
--- a/include/bb_archive.h
+++ b/include/bb_archive.h
@@ -116,6 +116,10 @@ typedef struct archive_handle_t {
116#if ENABLE_FEATURE_AR_CREATE 116#if ENABLE_FEATURE_AR_CREATE
117 const char *ar__name; 117 const char *ar__name;
118 struct archive_handle_t *ar__out; 118 struct archive_handle_t *ar__out;
119# if ENABLE_FEATURE_AR_LONG_FILENAMES
120 char *ar__long_names;
121 unsigned ar__long_name_size;
122# endif
119#endif 123#endif
120} archive_handle_t; 124} archive_handle_t;
121/* bits in ah_flags */ 125/* bits in ah_flags */