summaryrefslogtreecommitdiffhomepage
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)
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;
int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
#if ENABLE_FEATURE_COMPRESS_BBCONFIG
- bunzip_data *bd;
- int i;
- jmp_buf jmpbuf;
-
- /* Setup for I/O error handling via longjmp */
- i = setjmp(jmpbuf);
- if (i == 0) {
- i = start_bunzip(&jmpbuf,
- &bd,
- /* src_fd: */ -1,
- /* inbuf: */ bbconfig_config_bz2,
- /* len: */ sizeof(bbconfig_config_bz2)
- );
- }
- /* read_bunzip can longjmp and end up here with i != 0
- * on read data errors! Not trivial */
- if (i == 0) {
- /* Cannot use xmalloc: will leak bd in NOFORK case! */
- char *outbuf = malloc_or_warn(sizeof(bbconfig_config));
- if (outbuf) {
- read_bunzip(bd, outbuf, sizeof(bbconfig_config));
- full_write1_str(outbuf);
- }
+ const char *outbuf = unpack_bz2_data(bbconfig_config_bz2,
+ sizeof(bbconfig_config_bz2), sizeof(bbconfig_config));
+ if (outbuf) {
+ full_write1_str(outbuf);
}
#else
full_write1_str(bbconfig_config);