Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/blob.c
AgeCommit message (Collapse)Author
2022-02-10blob: clear buf->head when freeing a bufferFelix Fietkau
Prevents accidental silent use-after-free bugs Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-04-29blob: fix exceeding maximum buffer lengthZefir Kurtisi
Currently there is no measure in place to prevent the blob buffer to exceed its maximum allowed length of 16MB. Continuously calling blob_add() will expand the buffer until it exceeds BLOB_ATTR_LEN_MASK and after that will return valid blob_attr pointer without increasing the buflen. A test program was added in the previous commit, this one fixes the issue by asserting that the new bufflen after grow does not exceed BLOB_ATTR_LEN_MASK. Signed-off-by: Zefir Kurtisi <zefir.kurtisi@gmail.com>
2020-05-24blob: make blob_parse_untrusted more permissiveMatthias Schiffer
Some tools like ucert use concatenations of multiple blobs. Account for this case by allowing the underlying buffer length to be greater than the blob length. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2019-12-25blob: fix OOB access in blob_check_typePetr Štetiar
Found by fuzzer: ERROR: AddressSanitizer: SEGV on unknown address 0x602100000455 The signal is caused by a READ memory access. #0 in blob_check_type blob.c:214:43 #1 in blob_parse_attr blob.c:234:9 #2 in blob_parse_untrusted blob.c:272:12 #3 in fuzz_blob_parse tests/fuzzer/test-blob-parse-fuzzer.c:34:2 #4 in LLVMFuzzerTestOneInput tests/fuzzer/test-blob-parse-fuzzer.c:39:2 Caused by following line: if (type == BLOB_ATTR_STRING && data[len - 1] != 0) where len was pointing outside of the data buffer. Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-12-25blob: introduce blob_parse_untrustedPetr Štetiar
blob_parse can be only used on trusted input as it has no possibility to check the length of the provided input buffer, which might lead to undefined behaviour and/or crashes when supplied with malformed, corrupted or otherwise specially crafted input. So this introduces blob_parse_untrusted variant which expects additional input buffer length argument and thus should be able to process also inputs from untrusted sources. Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-12-25blob: refactor attr parsing into separate functionPetr Štetiar
Making blob_parse easier to review. Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-20iron out all extra compiler warningsPetr Štetiar
gcc-9 on x86/64 has reported following issues: base64.c:173:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:230:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:238:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:242:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:252:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:256:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:266:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:315:27: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] base64.c:329:15: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] blob.c:207:11: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] blob.c:210:11: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] blob.c:243:31: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare] blob.c:246:31: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare] blob.h:245:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] blob.h:253:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] blobmsg.h:269:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] blobmsg_json.c:155:10: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] examples/../blob.h:245:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] examples/../blobmsg.h:269:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare] json_script.c:590:7: error: this statement may fall through [-Werror=implicit-fallthrough=] Signed-off-by: Petr Štetiar <ynezz@true.cz>
2017-01-04blobmsg: add support for doubleAndré Gaul
This adds support for double floating point type to make it more JSON compatible. For type checking it also adds a stub BLOB_ATTR_DOUBLE type. If necessary, the accessor functions for blob can be added later Signed-off-by: André Gaul <andre@gaul.io> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2014-07-26blob: improve out-of-memory handlingewolfok
Signed-off-by: Chen Bin <ewolfok@126.com> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-27blob: make length variables unsignedFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-21blob: fix handling of custom validator callbackFelix Fietkau
https://dev.openwrt.org/ticket/15638 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-12blobmsg: allow data/length iterator/accessor functions to work on ↵Felix Fietkau
non-blobmsg elements This primarily helps with simplifying the ubus APIs. blobmsg header presence is indicated by the BLOB_ATTR_EXTENDED bit in the id_len field. This changes the format ABI, but not the API. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-16blob: add a magic offset to nesting cookies to ensure that NULL is never ↵Felix Fietkau
returned as a normal value Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-04blob: add blob_put_raw() for copying one or more blob attributes into the ↵Felix Fietkau
buffer directly Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-10blob: add blob_buf_grow()Felix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-06-01blob: add blob_memdup()Felix Fietkau
2011-11-10blob: switch to ISC license, switch blob_{get,put}_int* to _u*, add wrappersFelix Fietkau
2011-10-06fix more instances of uninitialized padding bytesFelix Fietkau
2011-10-06fill padding bytes when setting raw attribute lengthFelix Fietkau
2011-10-03explicitly zero extra buffer space added with realloc to silence valgrind ↵Felix Fietkau
warnings
2011-09-05blob_attr_equal: un-inline, add pointer checksFelix Fietkau
2011-07-29add blob_buf_freeFelix Fietkau
2011-01-31fix off-by-one in the string validation checkFelix Fietkau
2011-01-31blob: constifyFelix Fietkau
2011-01-31make blob attribute checking available externallyFelix Fietkau
2011-01-31blob: validate strings on parseFelix Fietkau
2010-12-06constify blob_attr_infoFelix Fietkau
2010-10-13Initial importFelix Fietkau