From 0ccf52a9fb9fa2f76eacbb6f1ef8419220557a40 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 17 Apr 2016 21:05:34 +0200 Subject: unzip: fix a case where we find wrong CDE. Closes 8821 function old new delta unzip_main 2472 2490 +18 Signed-off-by: Denys Vlasenko --- archival/unzip.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'archival/unzip.c') diff --git a/archival/unzip.c b/archival/unzip.c index f41ab6f44..b0a6ca836 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -45,6 +45,12 @@ #include "libbb.h" #include "bb_archive.h" +#if 0 +# define dbg(...) bb_error_msg(__VA_ARGS__) +#else +# define dbg(...) ((void)0) +#endif + enum { #if BB_BIG_ENDIAN ZIP_FILEHEADER_MAGIC = 0x504b0304, @@ -193,15 +199,17 @@ static uint32_t find_cdf_offset(void) unsigned char *p; off_t end; unsigned char *buf = xzalloc(PEEK_FROM_END); + uint32_t found; end = xlseek(zip_fd, 0, SEEK_END); end -= PEEK_FROM_END; if (end < 0) end = 0; - xlseek(zip_fd, end, SEEK_SET); + dbg("Looking for cdf_offset starting from 0x%"OFF_FMT"x", end); + xlseek(zip_fd, end, SEEK_SET); full_read(zip_fd, buf, PEEK_FROM_END); - cde_header.formatted.cdf_offset = BAD_CDF_OFFSET; + found = BAD_CDF_OFFSET; p = buf; while (p <= buf + PEEK_FROM_END - CDE_HEADER_LEN - 4) { if (*p != 'P') { @@ -220,14 +228,25 @@ static uint32_t find_cdf_offset(void) /* * I've seen .ZIP files with seemingly valid CDEs * where cdf_offset points past EOF - ?? - * Ignore such CDEs: + * This check ignores such CDEs: */ - if (cde_header.formatted.cdf_offset < end + (p - buf)) - break; - cde_header.formatted.cdf_offset = BAD_CDF_OFFSET; + if (cde_header.formatted.cdf_offset < end + (p - buf)) { + found = cde_header.formatted.cdf_offset; + dbg("Possible cdf_offset:0x%x at 0x%"OFF_FMT"x", + (unsigned)found, end + (p-3 - buf)); + dbg(" cdf_offset+cdf_size:0x%x", + (unsigned)(found + SWAP_LE32(cde_header.formatted.cdf_size))); + /* + * We do not "break" here because only the last CDE is valid. + * I've seen a .zip archive which contained a .zip file, + * uncompressed, and taking the first CDE was using + * the CDE inside that file! + */ + } } free(buf); - return cde_header.formatted.cdf_offset; + dbg("Found cdf_offset:0x%x", (unsigned)found); + return found; }; static uint32_t read_next_cdf(uint32_t cdf_offset, cdf_header_t *cdf_ptr) @@ -240,9 +259,13 @@ static uint32_t read_next_cdf(uint32_t cdf_offset, cdf_header_t *cdf_ptr) cdf_offset = find_cdf_offset(); if (cdf_offset != BAD_CDF_OFFSET) { + dbg("Reading CDF at 0x%x", (unsigned)cdf_offset); xlseek(zip_fd, cdf_offset + 4, SEEK_SET); xread(zip_fd, cdf_ptr->raw, CDF_HEADER_LEN); FIX_ENDIANNESS_CDF(*cdf_ptr); + dbg("file_name_length:%u", (unsigned)cdf_ptr->formatted.file_name_length); + dbg("extra_field_length:%u", (unsigned)cdf_ptr->formatted.extra_field_length); + dbg("file_comment_length:%u", (unsigned)cdf_ptr->formatted.file_comment_length); cdf_offset += 4 + CDF_HEADER_LEN + cdf_ptr->formatted.file_name_length + cdf_ptr->formatted.extra_field_length @@ -532,11 +555,14 @@ int unzip_main(int argc, char **argv) /* Check magic number */ xread(zip_fd, &magic, 4); /* Central directory? It's at the end, so exit */ - if (magic == ZIP_CDF_MAGIC) + if (magic == ZIP_CDF_MAGIC) { + dbg("got ZIP_CDF_MAGIC"); break; + } #if ENABLE_DESKTOP /* Data descriptor? It was a streaming file, go on */ if (magic == ZIP_DD_MAGIC) { + dbg("got ZIP_DD_MAGIC"); /* skip over duplicate crc32, cmpsize and ucmpsize */ unzip_skip(3 * 4); continue; @@ -544,6 +570,7 @@ int unzip_main(int argc, char **argv) #endif if (magic != ZIP_FILEHEADER_MAGIC) bb_error_msg_and_die("invalid zip magic %08X", (int)magic); + dbg("got ZIP_FILEHEADER_MAGIC"); /* Read the file header */ xread(zip_fd, zip_header.raw, ZIP_HEADER_LEN); -- cgit v1.2.3-55-g6feb From bca4deee8393395f77630ad320c306d06ea186ed Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 18 Apr 2016 01:14:05 +0200 Subject: unzip: fix percent overflow; show "stored" files properly Signed-off-by: Denys Vlasenko --- archival/unzip.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'archival/unzip.c') diff --git a/archival/unzip.c b/archival/unzip.c index b0a6ca836..7bf51f466 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -263,15 +263,18 @@ static uint32_t read_next_cdf(uint32_t cdf_offset, cdf_header_t *cdf_ptr) xlseek(zip_fd, cdf_offset + 4, SEEK_SET); xread(zip_fd, cdf_ptr->raw, CDF_HEADER_LEN); FIX_ENDIANNESS_CDF(*cdf_ptr); - dbg("file_name_length:%u", (unsigned)cdf_ptr->formatted.file_name_length); - dbg("extra_field_length:%u", (unsigned)cdf_ptr->formatted.extra_field_length); - dbg("file_comment_length:%u", (unsigned)cdf_ptr->formatted.file_comment_length); + dbg(" file_name_length:%u extra_field_length:%u file_comment_length:%u", + (unsigned)cdf_ptr->formatted.file_name_length, + (unsigned)cdf_ptr->formatted.extra_field_length, + (unsigned)cdf_ptr->formatted.file_comment_length + ); cdf_offset += 4 + CDF_HEADER_LEN + cdf_ptr->formatted.file_name_length + cdf_ptr->formatted.extra_field_length + cdf_ptr->formatted.file_comment_length; } + dbg("Returning file position to 0x%"OFF_FMT"x", org); xlseek(zip_fd, org, SEEK_SET); return cdf_offset; }; @@ -614,6 +617,11 @@ int unzip_main(int argc, char **argv) bb_error_msg_and_die("can't find file table"); } #endif + dbg("File cmpsize:0x%x extra_len:0x%x ucmpsize:0x%x", + (unsigned)zip_header.formatted.cmpsize, + (unsigned)zip_header.formatted.extra_len, + (unsigned)zip_header.formatted.ucmpsize + ); /* Read filename */ free(dst_fn); @@ -646,16 +654,31 @@ int unzip_main(int argc, char **argv) (dostime & 0x0000f800) >> 11, (dostime & 0x000007e0) >> 5, dst_fn); - total_usize += zip_header.formatted.ucmpsize; } else { unsigned long percents = zip_header.formatted.ucmpsize - zip_header.formatted.cmpsize; + if ((int32_t)percents < 0) + percents = 0; /* happens if ucmpsize < cmpsize */ percents = percents * 100; if (zip_header.formatted.ucmpsize) percents /= zip_header.formatted.ucmpsize; // " Length Method Size Ratio Date Time CRC-32 Name\n" // "-------- ------ ------- ----- ---- ---- ------ ----" - printf( "%8u Defl:N" "%9u%4u%% %02u-%02u-%02u %02u:%02u %08x %s\n", + printf( "%8u %s" "%9u%4u%% %02u-%02u-%02u %02u:%02u %08x %s\n", (unsigned)zip_header.formatted.ucmpsize, + zip_header.formatted.method == 0 ? "Stored" : "Defl:N", /* Defl is method 8 */ +/* TODO: show other methods? + * 1 - Shrunk + * 2 - Reduced with compression factor 1 + * 3 - Reduced with compression factor 2 + * 4 - Reduced with compression factor 3 + * 5 - Reduced with compression factor 4 + * 6 - Imploded + * 7 - Reserved for Tokenizing compression algorithm + * 9 - Deflate64 + * 10 - PKWARE Data Compression Library Imploding + * 11 - Reserved by PKWARE + * 12 - BZIP2 + */ (unsigned)zip_header.formatted.cmpsize, (unsigned)percents, (dostime & 0x01e00000) >> 21, @@ -665,9 +688,9 @@ int unzip_main(int argc, char **argv) (dostime & 0x000007e0) >> 5, zip_header.formatted.crc32, dst_fn); - total_usize += zip_header.formatted.ucmpsize; total_size += zip_header.formatted.cmpsize; } + total_usize += zip_header.formatted.ucmpsize; i = 'n'; } else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */ -- cgit v1.2.3-55-g6feb From 07bd9799217038391c8d299e6a2e031fef23c20b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 18 Apr 2016 01:43:24 +0200 Subject: unzip: better match for "standard" unzip's output; string shrinkage function old new delta unzip_main 2490 2426 -64 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-64) Total: -64 bytes text data bss dec hex filename 924008 906 17160 942074 e5ffa busybox_old 923846 906 17160 941912 e5f58 busybox_unstripped Signed-off-by: Denys Vlasenko --- archival/unzip.c | 62 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'archival/unzip.c') diff --git a/archival/unzip.c b/archival/unzip.c index 7bf51f466..a7532e0ff 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -514,11 +514,11 @@ int unzip_main(int argc, char **argv) printf("Archive: %s\n", src_fn); if (listing) { puts(verbose ? - " Length Method Size Ratio Date Time CRC-32 Name\n" - "-------- ------ ------- ----- ---- ---- ------ ----" + " Length Method Size Cmpr Date Time CRC-32 Name\n" + "-------- ------ ------- ---- ---------- ----- -------- ----" : - " Length Date Time Name\n" - " -------- ---- ---- ----" + " Length Date Time Name\n" + "--------- ---------- ----- ----" ); } } @@ -643,16 +643,20 @@ int unzip_main(int argc, char **argv) if (listing) { /* List entry */ unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16); - if (!verbose) { - // " Length Date Time Name\n" - // " -------- ---- ---- ----" - printf( "%9u %02u-%02u-%02u %02u:%02u %s\n", - (unsigned)zip_header.formatted.ucmpsize, + char dtbuf[sizeof("mm-dd-yyyy hh:mm")]; + sprintf(dtbuf, "%02u-%02u-%04u %02u:%02u", (dostime & 0x01e00000) >> 21, (dostime & 0x001f0000) >> 16, - (((dostime & 0xfe000000) >> 25) + 1980) % 100, + ((dostime & 0xfe000000) >> 25) + 1980, (dostime & 0x0000f800) >> 11, - (dostime & 0x000007e0) >> 5, + (dostime & 0x000007e0) >> 5 + ); + if (!verbose) { + // " Length Date Time Name\n" + // "--------- ---------- ----- ----" + printf( "%9u " "%s " "%s\n", + (unsigned)zip_header.formatted.ucmpsize, + dtbuf, dst_fn); } else { unsigned long percents = zip_header.formatted.ucmpsize - zip_header.formatted.cmpsize; @@ -661,9 +665,9 @@ int unzip_main(int argc, char **argv) percents = percents * 100; if (zip_header.formatted.ucmpsize) percents /= zip_header.formatted.ucmpsize; - // " Length Method Size Ratio Date Time CRC-32 Name\n" - // "-------- ------ ------- ----- ---- ---- ------ ----" - printf( "%8u %s" "%9u%4u%% %02u-%02u-%02u %02u:%02u %08x %s\n", + // " Length Method Size Cmpr Date Time CRC-32 Name\n" + // "-------- ------ ------- ---- ---------- ----- -------- ----" + printf( "%8u %s" "%9u%4u%% " "%s " "%08x " "%s\n", (unsigned)zip_header.formatted.ucmpsize, zip_header.formatted.method == 0 ? "Stored" : "Defl:N", /* Defl is method 8 */ /* TODO: show other methods? @@ -681,11 +685,7 @@ int unzip_main(int argc, char **argv) */ (unsigned)zip_header.formatted.cmpsize, (unsigned)percents, - (dostime & 0x01e00000) >> 21, - (dostime & 0x001f0000) >> 16, - (((dostime & 0xfe000000) >> 25) + 1980) % 100, - (dostime & 0x0000f800) >> 11, - (dostime & 0x000007e0) >> 5, + dtbuf, zip_header.formatted.crc32, dst_fn); total_size += zip_header.formatted.cmpsize; @@ -793,21 +793,25 @@ int unzip_main(int argc, char **argv) if (listing && quiet <= 1) { if (!verbose) { - // " Length Date Time Name\n" - // " -------- ---- ---- ----" - printf( " -------- -------\n" - "%9lu" " %u files\n", - total_usize, total_entries); + // " Length Date Time Name\n" + // "--------- ---------- ----- ----" + printf( " --------%21s" "-------\n" + "%9lu%21s" "%u files\n", + "", + total_usize, "", total_entries); } else { unsigned long percents = total_usize - total_size; + if ((long)percents < 0) + percents = 0; /* happens if usize < size */ percents = percents * 100; if (total_usize) percents /= total_usize; - // " Length Method Size Ratio Date Time CRC-32 Name\n" - // "-------- ------ ------- ----- ---- ---- ------ ----" - printf( "-------- ------- --- -------\n" - "%8lu" "%17lu%4u%% %u files\n", - total_usize, total_size, (unsigned)percents, + // " Length Method Size Cmpr Date Time CRC-32 Name\n" + // "-------- ------ ------- ---- ---------- ----- -------- ----" + printf( "-------- ------- ----%28s" "----\n" + "%8lu" "%17lu%4u%%%28s" "%u files\n", + "", + total_usize, total_size, (unsigned)percents, "", total_entries); } } -- cgit v1.2.3-55-g6feb From 5598bdf0d3d46a865a4d23785e2d09e6db9be420 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 18 Apr 2016 02:34:29 +0200 Subject: unzip: shorter code for date/time generation function old new delta unzip_main 2426 2414 -12 Signed-off-by: Denys Vlasenko --- archival/unzip.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'archival/unzip.c') diff --git a/archival/unzip.c b/archival/unzip.c index a7532e0ff..be32e60e2 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -642,14 +642,14 @@ int unzip_main(int argc, char **argv) } else { if (listing) { /* List entry */ - unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16); char dtbuf[sizeof("mm-dd-yyyy hh:mm")]; sprintf(dtbuf, "%02u-%02u-%04u %02u:%02u", - (dostime & 0x01e00000) >> 21, - (dostime & 0x001f0000) >> 16, - ((dostime & 0xfe000000) >> 25) + 1980, - (dostime & 0x0000f800) >> 11, - (dostime & 0x000007e0) >> 5 + (zip_header.formatted.moddate >> 5) & 0xf, // mm: 0x01e0 + (zip_header.formatted.moddate) & 0x1f, // dd: 0x001f + (zip_header.formatted.moddate >> 9) + 1980, // yy: 0xfe00 + (zip_header.formatted.modtime >> 11), // hh: 0xf800 + (zip_header.formatted.modtime >> 5) & 0x3f // mm: 0x07e0 + // seconds/2 are not shown, encoded in ----------- 0x001f ); if (!verbose) { // " Length Date Time Name\n" -- cgit v1.2.3-55-g6feb From 3e134ebf6afb5552b3619f98f6a2ffa01a07eebb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 22 Apr 2016 18:09:21 +0200 Subject: *: slap on a few ALIGN1/2s where appropriate The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map" text data bss dec hex filename 829901 4086 1904 835891 cc133 busybox_before 829665 4086 1904 835655 cc047 busybox Signed-off-by: Denys Vlasenko --- archival/libarchive/common.c | 2 +- archival/lzop.c | 2 +- archival/unzip.c | 2 +- coreutils/stty.c | 6 +++--- e2fsprogs/e2fs_lib.c | 4 ++-- editors/sed.c | 2 +- editors/vi.c | 2 +- init/bootchartd.c | 2 +- libbb/mode_string.c | 4 ++-- libbb/pw_encrypt.c | 2 +- libbb/u_signal_names.c | 2 +- miscutils/adjtimex.c | 6 +++--- miscutils/eject.c | 2 +- miscutils/ionice.c | 2 +- miscutils/setserial.c | 8 ++++---- networking/libiproute/ipneigh.c | 2 +- networking/libiproute/ll_proto.c | 2 +- networking/libiproute/ll_types.c | 4 ++-- networking/telnetd.ctrlSQ.patch | 4 ++-- networking/udhcp/dhcpc.c | 2 +- networking/wget.c | 6 +++--- procps/top.c | 6 +++--- shell/ash.c | 6 +++--- shell/shell_common.c | 2 +- util-linux/fatattr.c | 2 +- util-linux/mount.c | 6 +++--- util-linux/nsenter.c | 2 +- util-linux/unshare.c | 2 +- util-linux/volume_id/bcache.c | 2 +- util-linux/volume_id/luks.c | 2 +- 30 files changed, 49 insertions(+), 49 deletions(-) (limited to 'archival/unzip.c') diff --git a/archival/libarchive/common.c b/archival/libarchive/common.c index dd69d2222..389cb7856 100644 --- a/archival/libarchive/common.c +++ b/archival/libarchive/common.c @@ -6,4 +6,4 @@ #include "libbb.h" #include "bb_archive.h" -const char cpio_TRAILER[] = "TRAILER!!!"; +const char cpio_TRAILER[] ALIGN1 = "TRAILER!!!"; diff --git a/archival/lzop.c b/archival/lzop.c index 4afa21889..202de4d03 100644 --- a/archival/lzop.c +++ b/archival/lzop.c @@ -896,7 +896,7 @@ static NOINLINE int lzo_decompress(const header_t *h) * chksum_out * The rest is identical. */ -static const unsigned char lzop_magic[9] = { +static const unsigned char lzop_magic[9] ALIGN1 = { 0x89, 0x4c, 0x5a, 0x4f, 0x00, 0x0d, 0x0a, 0x1a, 0x0a }; diff --git a/archival/unzip.c b/archival/unzip.c index be32e60e2..c540485ac 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -487,7 +487,7 @@ int unzip_main(int argc, char **argv) if (overwrite == O_PROMPT) overwrite = O_NEVER; } else { - static const char extn[][5] = { ".zip", ".ZIP" }; + static const char extn[][5] ALIGN1 = { ".zip", ".ZIP" }; char *ext = src_fn + strlen(src_fn); int src_fd; diff --git a/coreutils/stty.c b/coreutils/stty.c index 0e32fc898..52967ea8f 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c @@ -318,7 +318,7 @@ enum { #define MI_ENTRY(N,T,F,B,M) N "\0" /* Mode names given on command line */ -static const char mode_name[] = +static const char mode_name[] ALIGN1 = MI_ENTRY("evenp", combination, REV | OMIT, 0, 0 ) MI_ENTRY("parity", combination, REV | OMIT, 0, 0 ) MI_ENTRY("oddp", combination, REV | OMIT, 0, 0 ) @@ -681,7 +681,7 @@ enum { #define CI_ENTRY(n,s,o) n "\0" /* Name given on command line */ -static const char control_name[] = +static const char control_name[] ALIGN1 = CI_ENTRY("intr", CINTR, VINTR ) CI_ENTRY("quit", CQUIT, VQUIT ) CI_ENTRY("erase", CERASE, VERASE ) @@ -723,7 +723,7 @@ static const char control_name[] = #undef CI_ENTRY #define CI_ENTRY(n,s,o) { s, o }, -static const struct control_info control_info[] = { +static const struct control_info control_info[] ALIGN2 = { /* This should be verbatim cut-n-paste copy of the above CI_ENTRYs */ CI_ENTRY("intr", CINTR, VINTR ) CI_ENTRY("quit", CQUIT, VQUIT ) diff --git a/e2fsprogs/e2fs_lib.c b/e2fsprogs/e2fs_lib.c index a6aec9484..6ce655be3 100644 --- a/e2fsprogs/e2fs_lib.c +++ b/e2fsprogs/e2fs_lib.c @@ -149,14 +149,14 @@ const uint32_t e2attr_flags_value[] = { EXT2_TOPDIR_FL }; -const char e2attr_flags_sname[] = +const char e2attr_flags_sname[] ALIGN1 = #ifdef ENABLE_COMPRESSION "BZXE" #endif "I" "suSDiadAcjtT"; -static const char e2attr_flags_lname[] = +static const char e2attr_flags_lname[] ALIGN1 = #ifdef ENABLE_COMPRESSION "Compressed_File" "\0" "Compressed_Dirty_File" "\0" diff --git a/editors/sed.c b/editors/sed.c index ed48de17f..6bce25b2c 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -473,7 +473,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr) */ static const char *parse_cmd_args(sed_cmd_t *sed_cmd, const char *cmdstr) { - static const char cmd_letters[] = "saicrw:btTydDgGhHlnNpPqx={}"; + static const char cmd_letters[] ALIGN1 = "saicrw:btTydDgGhHlnNpPqx={}"; enum { IDX_s = 0, IDX_a, diff --git a/editors/vi.c b/editors/vi.c index f355712ab..974f9978b 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -251,7 +251,7 @@ enum { // cmds modifying text[] // vda: removed "aAiIs" as they switch us into insert mode // and remembering input for replay after them makes no sense -static const char modifying_cmds[] = "cCdDJoOpPrRxX<>~"; +static const char modifying_cmds[] ALIGN1 = "cCdDJoOpPrRxX<>~"; #endif enum { diff --git a/init/bootchartd.c b/init/bootchartd.c index 7f511e650..92aaade0f 100644 --- a/init/bootchartd.c +++ b/init/bootchartd.c @@ -194,7 +194,7 @@ static char *make_tempdir(void) * Since we unmount it at once, we can mount it anywhere. * Try a few locations which are likely ti exist. */ - static const char dirs[] = "/mnt\0""/tmp\0""/boot\0""/proc\0"; + static const char dirs[] ALIGN1 = "/mnt\0""/tmp\0""/boot\0""/proc\0"; const char *try_dir = dirs; while (mount("none", try_dir, "tmpfs", MS_SILENT, "size=16m") != 0) { try_dir += strlen(try_dir) + 1; diff --git a/libbb/mode_string.c b/libbb/mode_string.c index f1afe7d61..934eb6dc7 100644 --- a/libbb/mode_string.c +++ b/libbb/mode_string.c @@ -87,9 +87,9 @@ const char* FAST_FUNC bb_mode_string(mode_t mode) /* The previous version used "0pcCd?bB-?l?s???". However, the '0', 'C', * and 'B' types don't appear to be available on linux. So I removed them. */ -static const char type_chars[16] = "?pc?d?b?-?l?s???"; +static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???"; /********************************** 0123456789abcdef */ -static const char mode_chars[7] = "rwxSTst"; +static const char mode_chars[7] ALIGN1 = "rwxSTst"; const char* FAST_FUNC bb_mode_string(mode_t mode) { diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c index dbc15e5fc..4cdc2de76 100644 --- a/libbb/pw_encrypt.c +++ b/libbb/pw_encrypt.c @@ -9,7 +9,7 @@ #include "libbb.h" -/* static const uint8_t ascii64[] = +/* static const uint8_t ascii64[] ALIGN1 = * "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; */ diff --git a/libbb/u_signal_names.c b/libbb/u_signal_names.c index 8c78f5e20..b49714f2a 100644 --- a/libbb/u_signal_names.c +++ b/libbb/u_signal_names.c @@ -19,7 +19,7 @@ /* Believe it or not, but some arches have more than 32 SIGs! * HPPA: SIGSTKFLT == 36. */ -static const char signals[][7] = { +static const char signals[][7] ALIGN1 = { // SUSv3 says kill must support these, and specifies the numerical values, // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html // {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"}, diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c index 534364a69..058aa9a5c 100644 --- a/miscutils/adjtimex.c +++ b/miscutils/adjtimex.c @@ -29,7 +29,7 @@ # include #endif -static const uint16_t statlist_bit[] = { +static const uint16_t statlist_bit[] ALIGN2 = { STA_PLL, STA_PPSFREQ, STA_PPSTIME, @@ -45,7 +45,7 @@ static const uint16_t statlist_bit[] = { STA_CLOCKERR, 0 }; -static const char statlist_name[] = +static const char statlist_name[] ALIGN1 = "PLL" "\0" "PPSFREQ" "\0" "PPSTIME" "\0" @@ -61,7 +61,7 @@ static const char statlist_name[] = "CLOCKERR" ; -static const char ret_code_descript[] = +static const char ret_code_descript[] ALIGN1 = "clock synchronized" "\0" "insert leap second" "\0" "delete leap second" "\0" diff --git a/miscutils/eject.c b/miscutils/eject.c index e33d79127..16ae250ff 100644 --- a/miscutils/eject.c +++ b/miscutils/eject.c @@ -40,7 +40,7 @@ #if ENABLE_FEATURE_EJECT_SCSI static void eject_scsi(const char *dev) { - static const char sg_commands[3][6] = { + static const char sg_commands[3][6] ALIGN1 = { { ALLOW_MEDIUM_REMOVAL, 0, 0, 0, 0, 0 }, { START_STOP, 0, 0, 0, 1, 0 }, { START_STOP, 0, 0, 0, 2, 0 } diff --git a/miscutils/ionice.c b/miscutils/ionice.c index bd300605f..0c14256ab 100644 --- a/miscutils/ionice.c +++ b/miscutils/ionice.c @@ -41,7 +41,7 @@ enum { IOPRIO_CLASS_IDLE }; -static const char to_prio[] = "none\0realtime\0best-effort\0idle"; +static const char to_prio[] ALIGN1 = "none\0realtime\0best-effort\0idle"; #define IOPRIO_CLASS_SHIFT 13 diff --git a/miscutils/setserial.c b/miscutils/setserial.c index dfed3306e..8b5c4a9c7 100644 --- a/miscutils/setserial.c +++ b/miscutils/setserial.c @@ -257,7 +257,7 @@ enum print_mode #define CTL_CLOSE (1 << 3) #define CTL_NODIE (1 << 4) -static const char serial_types[] = +static const char serial_types[] ALIGN1 = "unknown\0" /* 0 */ "8250\0" /* 1 */ "16450\0" /* 2 */ @@ -288,7 +288,7 @@ static const char serial_types[] = # define MAX_SERIAL_TYPE 13 #endif -static const char commands[] = +static const char commands[] ALIGN1 = "spd_normal\0" "spd_hi\0" "spd_vhi\0" @@ -404,8 +404,8 @@ static const uint16_t setbits[CMD_FLAG_LAST + 1] = ASYNC_LOW_LATENCY }; -static const char STR_INFINITE[] = "infinite"; -static const char STR_NONE[] = "none"; +#define STR_INFINITE "infinite" +#define STR_NONE "none" static const char *uart_type(int type) { diff --git a/networking/libiproute/ipneigh.c b/networking/libiproute/ipneigh.c index d2028b7b6..2a1c20e20 100644 --- a/networking/libiproute/ipneigh.c +++ b/networking/libiproute/ipneigh.c @@ -62,7 +62,7 @@ static unsigned nud_state_a2n(char *arg) "stale\0" "incomplete\0" "delay\0" "probe\0" "failed\0" ; - static uint8_t nuds[] = { + static uint8_t nuds[] ALIGN1 = { NUD_PERMANENT,NUD_REACHABLE, NUD_NOARP,NUD_NONE, NUD_STALE, NUD_INCOMPLETE,NUD_DELAY,NUD_PROBE, NUD_FAILED diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c index da2b53cbf..4c32ae574 100644 --- a/networking/libiproute/ll_proto.c +++ b/networking/libiproute/ll_proto.c @@ -84,7 +84,7 @@ ETH_P_IP /* Keep declarations above and below in sync! */ -static const char llproto_names[] = +static const char llproto_names[] ALIGN1 = #define __PF(f,n) #n "\0" __PF(LOOP,loop) __PF(PUP,pup) diff --git a/networking/libiproute/ll_types.c b/networking/libiproute/ll_types.c index bb42e269e..62ee0cc54 100644 --- a/networking/libiproute/ll_types.c +++ b/networking/libiproute/ll_types.c @@ -16,7 +16,7 @@ const char* FAST_FUNC ll_type_n2a(int type, char *buf) { - static const char arphrd_name[] = + static const char arphrd_name[] ALIGN1 = /* 0, */ "generic" "\0" /* ARPHRD_LOOPBACK, */ "loopback" "\0" /* ARPHRD_ETHER, */ "ether" "\0" @@ -105,7 +105,7 @@ const char* FAST_FUNC ll_type_n2a(int type, char *buf) /* Keep these arrays in sync! */ - static const uint16_t arphrd_type[] = { + static const uint16_t arphrd_type[] ALIGN2 = { 0, /* "generic" "\0" */ ARPHRD_LOOPBACK, /* "loopback" "\0" */ ARPHRD_ETHER, /* "ether" "\0" */ diff --git a/networking/telnetd.ctrlSQ.patch b/networking/telnetd.ctrlSQ.patch index 7060e1c6e..bc26d2279 100644 --- a/networking/telnetd.ctrlSQ.patch +++ b/networking/telnetd.ctrlSQ.patch @@ -94,9 +94,9 @@ exceptional conditions. #endif +#ifdef TIOCPKT + int control; -+ static const char lflow_on[] = ++ static const char lflow_on[] ALIGN1 = + {IAC, SB, TELOPT_LFLOW, LFLOW_ON, IAC, SE}; -+ static const char lflow_off[] = ++ static const char lflow_off[] ALIGN1 = + {IAC, SB, TELOPT_LFLOW, LFLOW_OFF, IAC, SE}; +# define RESERVED sizeof(lflow_on) +#else diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 8f5a03f2e..fc7b6216d 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -109,7 +109,7 @@ enum { /*** Script execution code ***/ /* get a rough idea of how long an option will be (rounding up...) */ -static const uint8_t len_of_option_as_string[] = { +static const uint8_t len_of_option_as_string[] ALIGN1 = { [OPTION_IP ] = sizeof("255.255.255.255 "), [OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2, [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "), diff --git a/networking/wget.c b/networking/wget.c index 5c12423c7..28c12540b 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -146,10 +146,10 @@ struct host_info { char *host; int port; }; -static const char P_FTP[] = "ftp"; -static const char P_HTTP[] = "http"; +static const char P_FTP[] ALIGN1 = "ftp"; +static const char P_HTTP[] ALIGN1 = "http"; #if ENABLE_FEATURE_WGET_OPENSSL || ENABLE_FEATURE_WGET_SSL_HELPER -static const char P_HTTPS[] = "https"; +static const char P_HTTPS[] ALIGN1 = "https"; #endif #if ENABLE_FEATURE_WGET_LONG_OPTIONS diff --git a/procps/top.c b/procps/top.c index 640bcdc6d..73cd285f0 100644 --- a/procps/top.c +++ b/procps/top.c @@ -265,9 +265,9 @@ static int mult_lvl_cmp(void* a, void* b) static NOINLINE int read_cpu_jiffy(FILE *fp, jiffy_counts_t *p_jif) { #if !ENABLE_FEATURE_TOP_SMP_CPU - static const char fmt[] = "cpu %llu %llu %llu %llu %llu %llu %llu %llu"; + static const char fmt[] ALIGN1 = "cpu %llu %llu %llu %llu %llu %llu %llu %llu"; #else - static const char fmt[] = "cp%*s %llu %llu %llu %llu %llu %llu %llu %llu"; + static const char fmt[] ALIGN1 = "cp%*s %llu %llu %llu %llu %llu %llu %llu %llu"; #endif int ret; @@ -519,7 +519,7 @@ enum { static void parse_meminfo(unsigned long meminfo[MI_MAX]) { - static const char fields[] = + static const char fields[] ALIGN1 = "MemTotal\0" "MemFree\0" "MemShared\0" diff --git a/shell/ash.c b/shell/ash.c index da9c95045..faa45a8dc 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -2750,7 +2750,7 @@ pwdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) #else # define SIT_ITEM(a,b,c,d) (a | (b << 4) | (c << 8)) #endif -static const uint16_t S_I_T[] = { +static const uint16_t S_I_T[] ALIGN2 = { #if ENABLE_ASH_ALIAS SIT_ITEM(CSPCL , CIGN , CIGN , CIGN ), /* 0, PEOA */ #endif @@ -2852,7 +2852,7 @@ SIT(int c, int syntax) #else /* !USE_SIT_FUNCTION */ -static const uint8_t syntax_index_table[] = { +static const uint8_t syntax_index_table[] ALIGN1 = { /* BASESYNTAX_DQSYNTAX_SQSYNTAX_ARISYNTAX */ /* 0 */ CWORD_CWORD_CWORD_CWORD, /* 1 */ CWORD_CWORD_CWORD_CWORD, @@ -7977,7 +7977,7 @@ static char *funcstring; /* block to allocate strings from */ #define EV_TESTED 02 /* exit status is checked; ignore -e flag */ #define EV_BACKCMD 04 /* command executing within back quotes */ -static const uint8_t nodesize[N_NUMBER] = { +static const uint8_t nodesize[N_NUMBER] ALIGN1 = { [NCMD ] = SHELL_ALIGN(sizeof(struct ncmd)), [NPIPE ] = SHELL_ALIGN(sizeof(struct npipe)), [NREDIR ] = SHELL_ALIGN(sizeof(struct nredir)), diff --git a/shell/shell_common.c b/shell/shell_common.c index 8c9607c8c..14eeaafcc 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c @@ -328,7 +328,7 @@ enum { }; /* "-": treat args as parameters of option with ASCII code 1 */ -static const char ulimit_opt_string[] = "-HSa" +static const char ulimit_opt_string[] ALIGN1 = "-HSa" #ifdef RLIMIT_FSIZE "f::" #endif diff --git a/util-linux/fatattr.c b/util-linux/fatattr.c index 5d933874a..6dca24a73 100644 --- a/util-linux/fatattr.c +++ b/util-linux/fatattr.c @@ -42,7 +42,7 @@ * Extra space at the end is a hack to print space separator in file listing. * Let's hope no one ever passes space as an option char :) */ -static const char bit_to_char[] = "rhsvda67 "; +static const char bit_to_char[] ALIGN1 = "rhsvda67 "; static inline unsigned long get_flag(char c) { diff --git a/util-linux/mount.c b/util-linux/mount.c index 244f4fa27..c76f6ef61 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -377,7 +377,7 @@ static const int32_t mount_options[] = { /* "remount" */ MS_REMOUNT // action flag }; -static const char mount_option_str[] = +static const char mount_option_str[] ALIGN1 = IF_FEATURE_MOUNT_LOOP( "loop\0" ) @@ -1003,7 +1003,7 @@ enum { # define EDQUOT ENOSPC #endif /* Convert each NFSERR_BLAH into EBLAH */ -static const uint8_t nfs_err_stat[] = { +static const uint8_t nfs_err_stat[] ALIGN1 = { 1, 2, 5, 6, 13, 17, 19, 20, 21, 22, 27, 28, 30, 63, 66, 69, 70, 71 @@ -1016,7 +1016,7 @@ typedef uint8_t nfs_err_type; #else typedef uint16_t nfs_err_type; #endif -static const nfs_err_type nfs_err_errnum[] = { +static const nfs_err_type nfs_err_errnum[] ALIGN2 = { EPERM , ENOENT , EIO , ENXIO , EACCES, EEXIST, ENODEV, ENOTDIR , EISDIR , EINVAL, EFBIG , ENOSPC, EROFS , ENAMETOOLONG, ENOTEMPTY, EDQUOT, ESTALE, EREMOTE diff --git a/util-linux/nsenter.c b/util-linux/nsenter.c index b08b3dae7..6834292da 100644 --- a/util-linux/nsenter.c +++ b/util-linux/nsenter.c @@ -128,7 +128,7 @@ static const struct namespace_descr ns_list[] = { /* * Upstream nsenter doesn't support the short option for --preserve-credentials */ -static const char opt_str[] = "U::i::u::n::p::m::""t+S+G+r::w::F"; +static const char opt_str[] ALIGN1 = "U::i::u::n::p::m::""t+S+G+r::w::F"; #if ENABLE_FEATURE_NSENTER_LONG_OPTS static const char nsenter_longopts[] ALIGN1 = diff --git a/util-linux/unshare.c b/util-linux/unshare.c index d05cfdb6c..fa7086add 100644 --- a/util-linux/unshare.c +++ b/util-linux/unshare.c @@ -137,7 +137,7 @@ static const struct namespace_descr ns_list[] = { * we are forced to use "fake" letters for them. * '+': stop at first non-option. */ -static const char opt_str[] = "+muinpU""fr""\xfd::""\xfe:""\xff:"; +static const char opt_str[] ALIGN1 = "+muinpU""fr""\xfd::""\xfe:""\xff:"; static const char unshare_longopts[] ALIGN1 = "mount\0" Optional_argument "\xf0" "uts\0" Optional_argument "\xf1" diff --git a/util-linux/volume_id/bcache.c b/util-linux/volume_id/bcache.c index 648e44de5..fd40eb081 100644 --- a/util-linux/volume_id/bcache.c +++ b/util-linux/volume_id/bcache.c @@ -24,7 +24,7 @@ #define SB_LABEL_SIZE 32 #define SB_JOURNAL_BUCKETS 256U -static const char bcache_magic[] = { +static const char bcache_magic[] ALIGN1 = { 0xc6, 0x85, 0x73, 0xf6, 0x4e, 0x1a, 0x45, 0xca, 0x82, 0x65, 0xf5, 0x7f, 0x48, 0xba, 0x6d, 0x81 }; diff --git a/util-linux/volume_id/luks.c b/util-linux/volume_id/luks.c index 42bf87659..21cb26f51 100644 --- a/util-linux/volume_id/luks.c +++ b/util-linux/volume_id/luks.c @@ -40,7 +40,7 @@ #define LUKS_SALTSIZE 32 #define LUKS_NUMKEYS 8 -static const uint8_t LUKS_MAGIC[] = { 'L','U','K','S', 0xba, 0xbe }; +static const uint8_t LUKS_MAGIC[] ALIGN1 = { 'L','U','K','S', 0xba, 0xbe }; struct luks_phdr { uint8_t magic[LUKS_MAGIC_L]; -- cgit v1.2.3-55-g6feb