aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-11-02 14:14:31 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-11-02 14:14:51 +0100
commitc339c7f7b393fbcd51b0f96df837baa1edad7fd8 (patch)
tree3fa49732a3426e0666ba732da7e4182db7dc66ca /miscutils
parent0df289f427da6279e3ca198d14e90015c079af44 (diff)
downloadbusybox-w32-c339c7f7b393fbcd51b0f96df837baa1edad7fd8.tar.gz
busybox-w32-c339c7f7b393fbcd51b0f96df837baa1edad7fd8.tar.bz2
busybox-w32-c339c7f7b393fbcd51b0f96df837baa1edad7fd8.zip
libarchive: add a function to unpack embedded data
Similar code to unpack embedded data is used to decompress usage messages, embedded scripts and the config file (in the non-default bbconfig applet). Moving this code to a common function reduces the size of the default build and hides more of the internals of libarchive. function old new delta unpack_bz2_data - 135 +135 bb_show_usage 137 157 +20 get_script_content 32 47 +15 unpack_scripts 119 - -119 unpack_usage_messages 124 - -124 ------------------------------------------------------------------------------ (add/remove: 1/2 grow/shrink: 2/0 up/down: 170/-243) Total: -73 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bbconfig.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/miscutils/bbconfig.c b/miscutils/bbconfig.c
index 501349548..fe02516a8 100644
--- a/miscutils/bbconfig.c
+++ b/miscutils/bbconfig.c
@@ -43,29 +43,10 @@ int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
43int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 43int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
44{ 44{
45#if ENABLE_FEATURE_COMPRESS_BBCONFIG 45#if ENABLE_FEATURE_COMPRESS_BBCONFIG
46 bunzip_data *bd; 46 const char *outbuf = unpack_bz2_data(bbconfig_config_bz2,
47 int i; 47 sizeof(bbconfig_config_bz2), sizeof(bbconfig_config));
48 jmp_buf jmpbuf; 48 if (outbuf) {
49 49 full_write1_str(outbuf);
50 /* Setup for I/O error handling via longjmp */
51 i = setjmp(jmpbuf);
52 if (i == 0) {
53 i = start_bunzip(&jmpbuf,
54 &bd,
55 /* src_fd: */ -1,
56 /* inbuf: */ bbconfig_config_bz2,
57 /* len: */ sizeof(bbconfig_config_bz2)
58 );
59 }
60 /* read_bunzip can longjmp and end up here with i != 0
61 * on read data errors! Not trivial */
62 if (i == 0) {
63 /* Cannot use xmalloc: will leak bd in NOFORK case! */
64 char *outbuf = malloc_or_warn(sizeof(bbconfig_config));
65 if (outbuf) {
66 read_bunzip(bd, outbuf, sizeof(bbconfig_config));
67 full_write1_str(outbuf);
68 }
69 } 50 }
70#else 51#else
71 full_write1_str(bbconfig_config); 52 full_write1_str(bbconfig_config);