summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* lzo: check for length overrun in variable length encoding.Stefan Müller-Klieser2015-03-251-6/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This corresponds to kernel commit 72cf90124e87d975d0b This fix ensures that we never meet an integer overflow while adding 255 while parsing a variable length encoding. It works differently from commit 206a81c ("lzo: properly check for overruns") because instead of ensuring that we don't overrun the input, which is tricky to guarantee due to many assumptions in the code, it simply checks that the cumulated number of 255 read cannot overflow by bounding this number. The MAX_255_COUNT is the maximum number of times we can add 255 to a base count without overflowing an integer. The multiply will overflow when multiplying 255 by more than MAXINT/255. The sum will overflow earlier depending on the base count. Since the base count is taken from a u8 and a few bits, it is safe to assume that it will always be lower than or equal to 2*255, thus we can always prevent any overflow by accepting two less 255 steps. This patch also reduces the CPU overhead and actually increases performance by 1.1% compared to the initial code, while the previous fix costs 3.1% (measured on x86_64). The fix needs to be backported to all currently supported stable kernels. Reported-by: Willem Pinckaers <willem@lekkertech.net> Cc: "Don A. Bailey" <donb@securitymouse.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "lzo: properly check for overruns"Stefan Müller-Klieser2015-03-251-42/+22
| | | | | | | | | | | | | | | | | This reverts barebox commit ecb1dc0b1e859bca9 This corresponds to kernel commit af958a38a60c7ca3d8 As analysed by Willem Pinckaers, this fix is still incomplete on certain rare corner cases, and it is easier to restart from the original code. Reported-by: Willem Pinckaers <willem@lekkertech.net> Cc: "Don A. Bailey" <donb@securitymouse.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib: Add hex2bin and bin2hex implementationsSascha Hauer2015-03-133-2/+75
| | | | | | | Taken from the Kernel, put into the same place as in the kernel, although the hexdump.c does not actually contain hexdum functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/rockchip'Sascha Hauer2015-03-092-0/+19
|\ | | | | | | | | Conflicts: arch/arm/Kconfig
| * lib: Add gcd() functionAndrey Panov2015-03-052-0/+19
| | | | | | | | | | | | | | It calculates greatest common divisor. Signed-off-by: Andrey Panov <rockford@yandex.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | cmndlinepart: skip devname if partstr already contains itSascha Hauer2015-02-121-1/+2
| | | | | | | | | | | | | | When the partition name already starts with "devname." skip this when adding the partition. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | cmdlinepart: add function to parse a cmdline partition stringSascha Hauer2015-02-121-0/+28
| | | | | | | | | | | | | | This adds a function to parse a full cmdline partition string. The addpart command is switched to use this function. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | cmdlinepart: make argument types saferSascha Hauer2015-02-121-3/+3
| | | | | | | | | | | | | | The return size should be loff_t to support partitions bigger than 4G. Also use const for the devname and endp. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | cmdlinepart: Change SIZE_REMAINING to loff_tSascha Hauer2015-02-121-1/+1
| | | | | | | | | | | | For compatibility with devices > 4G. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | move cmdline partition parsing code to separate fileSascha Hauer2015-02-122-0/+96
|/ | | | | | | So it's no longer local to the addpart/delpart code and can be used from other code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2015-02-041-2/+5
|\
| * param: add error check to __dev_add_param()Masahiro Yamada2015-02-021-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | If strdup() fails with out-of-memory, __dev_add_param() should fail with -ENOMEM. (Note strdup() is always given with a non-NULL pointer. If the argument name is given with NULL, the system would already have crashed in the get_param_by_name() function.) Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * param: add error check to dev_param_set_generic()Masahiro Yamada2015-02-021-1/+1
| | | | | | | | | | | | | | | | The function dev_param_set_generic() may fail because of out of memory. If so, return -ENOMEM. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib: decompress: remove redundant INT_MAX defineMasahiro Yamada2015-01-211-4/+0
|/ | | | | | | | lib/decompress_bunzip2.c includes <common.h> and INT_MAX is already defined there. The definition in this file is redundant. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mxs'Sascha Hauer2015-01-093-90/+88
|\
| * Add PBL console supportSascha Hauer2015-01-052-0/+14
| | | | | | | | | | | | | | | | | | | | | | This adds simple console support to the PBL which makes it possible to print more complex messages in the PBL than just strings or hex numbers. For now puts_ll is used to print the messages, so it depends on CONFIG_DEBUG_LL which makes it more a debugging option. However, this could be extended later to get regular output from the PBL if desired. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * printf: use local isdigit/isalnum implementationSascha Hauer2015-01-051-3/+5
| | | | | | | | | | | | | | To be independent of the _ctype array. This makes it possible to add printf support to the PBL without adding _ctype aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * printf: move simple_strto*() functions to separate fileSascha Hauer2015-01-053-66/+69
| | | | | | | | | | | | These are not needed in the PBL, so move them to a separate file. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * printf: move panic() to common/misc.cSascha Hauer2015-01-051-21/+0
| | | | | | | | | | | | | | | | panic() is not really a printf like function, so move it to common/misc.c. This is done because we want to have printf support in the PBL, but PBL has it's own panic() implementation. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2015-01-092-2/+2
|\ \
| * | sizes.h: move include/sizes.h to include/linux/sizes.hMasahiro Yamada2015-01-082-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | This file originates in Linux. Linux has it under include/linux/ directory since commit dccd2304cc90. Let's move it to the same place as well in barebox. This commit was generated by the following commands: find -name '*.[chS]' | xargs sed -i -e 's:<sizes.h>:<linux/sizes.h>:' git mv include/sizes.h include/linux/ Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/efi'Sascha Hauer2015-01-091-0/+16
|\ \
| * | lib: add wchar strdupLucas Stach2014-12-091-0/+16
| |/ | | | | | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / graphic_utils: set_pixel only write 16bit in 16bit modeJean-Christophe PLAGNIOL-VILLARD2015-01-051-1/+1
|/ | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/randconfig-1'Sascha Hauer2014-12-081-1/+1
|\
| * param: make string arguments to dev_add_param_fixed constSascha Hauer2014-11-281-1/+1
| | | | | | | | | | | | | | dev_add_param_fixed does not modify the strings, so make them const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/persistent-vars'Sascha Hauer2014-12-081-0/+40
|\ \ | | | | | | | | | | | | Conflicts: arch/arm/boards/efika-mx-smartbook/defaultenv-efikasb/config
| * | libfile: Add copy_recursiveSascha Hauer2014-11-061-0/+40
| | | | | | | | | | | | | | | | | | To recursively copy a directory tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/misc'Sascha Hauer2014-12-081-3/+3
|\ \ \ | |_|/ |/| |
| * | stringlist: the string argument should be constJan Luebbe2014-12-041-2/+2
| | | | | | | | | | | | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | stringlist: string_list_contains can use a const stringJan Luebbe2014-11-201-1/+1
| |/ | | | | | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib: decompress_xz: fix function header to match prototypeLucas Stach2014-11-241-4/+4
| | | | | | | | | | | | | | | | Fixes: lib/uncompress.c:124:10: warning: assignment from incompatible pointer type Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | xymodem: select CRC16 from libJan Weitzel2014-11-121-0/+1
|/ | | | | Signed-off-by: Jan Weitzel <j.weitzel@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/xz'Sascha Hauer2014-11-0512-0/+3439
|\
| * Add xz decompression supportSascha Hauer2014-11-0412-0/+3439
| | | | | | | | | | | | | | | | This adds xz decompression support from the kernel. Both compressing the barebox binary with xz and decompressing xz files on the commandline is supported. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2014-11-051-3/+5
|\ \
| * | param: let dev_add_param return the newly created paramSascha Hauer2014-10-081-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | dev_add_param creates a new parameter so it makes more sense to return it than to return an error code. Since the return value is hardly ever checked this is only a small patch. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/fs'Sascha Hauer2014-11-051-0/+71
|\ \ \ | |_|/ |/| |
| * | libfile: add compare_file functionSascha Hauer2014-10-091-0/+71
| |/ | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / lib: parameter: fixed doku renamed ip -> ipaddrRolf Evers-Fischer2014-10-231-2/+2
|/ | | | | | | Long time ago all ".ip" parameters have been replaced with ".ipaddr". Signed-off-by: Rolf Evers-Fischer <embedded24@evers-fischer.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* read_file_2: Fix return valueTeresa Gámez2014-09-251-1/+3
| | | | | | | | Set return value correct in error case. This prevents barebox from crashing in some conditions. Signed-off-by: Teresa Gámez <t.gamez@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: Fix history prev when history is emptySascha Hauer2014-09-011-1/+5
| | | | | | | | | | | | | | | | We cannot use list_entry() on an empty list. Without history we have to return an empty line. This fixes a crash when the cursor up button is pressed and no command has been entered previously. Broken since: commit ada160a34a1ec8421d5bb7b9dd746294668a5130 Author: Sascha Hauer <s.hauer@pengutronix.de> Date: Tue Jul 29 11:54:26 2014 +0200 readline: reimplement history functions Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Teresa Gamez <t.gamez@phytec.de>
* Merge branch 'for-next/usb-gadget'Sascha Hauer2014-08-071-0/+76
|\ | | | | | | | | | | | | | | Conflicts: commands/Makefile common/Kconfig common/Makefile drivers/usb/gadget/dfu.c
| * param: Add dev_add_param_stringSascha Hauer2014-07-221-0/+76
| | | | | | | | | | | | | | | | This function allows drivers to create a string parameter and provides access to it via a pointer. Using regular dev_add_param only allows access via dev_get_param(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/rtc'Sascha Hauer2014-08-072-0/+15
|\ \ | | | | | | | | | | | | | | | Conflicts: arch/mips/dts/jz4755.dtsi commands/Makefile
| * | lib: import 'bcd' from linux-3.15Antony Pavlov2014-07-312-0/+15
| | | | | | | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/misc'Sascha Hauer2014-08-073-68/+894
|\ \ \ | | | | | | | | | | | | | | | | Conflicts: lib/Makefile
| * | | readline: reimplement history functionsSascha Hauer2014-07-291-68/+54
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reimplements the history functions in readline. - Use regular lists instead of homegrown list implementation - Allocate history strings dynamically instead of copying strings to fixed buffers without checking the size - saves us an initcall - slightly smaller - no longer add duplicates to the history - when moving past the last history entry print an empty line Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | lib: Add bitmap functions from kernelSascha Hauer2014-07-172-0/+840
| |/ | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/metadata'Sascha Hauer2014-08-076-180/+334
|\ \ | | | | | | | | | | | | | | | | | | Conflicts: arch/arm/dts/Makefile common/Makefile lib/Makefile