projects
/
project
/
opkg-lede.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a5de03e
)
libopkg: make checksum_bin2hex() and checksum_hex2bin() cope with NULL
author
Jo-Philipp Wich
<
[email protected]
>
Wed, 15 Feb 2017 22:42:58 +0000
(23:42 +0100)
committer
Jo-Philipp Wich
<
[email protected]
>
Thu, 16 Feb 2017 16:02:29 +0000
(17:02 +0100)
Those functions may be called with a NULL source pointer, especially during
pkg_merge(), so allow that to keep call sites simple.
Signed-off-by: Jo-Philipp Wich <
[email protected]
>
libopkg/file_util.c
patch
|
blob
|
history
diff --git
a/libopkg/file_util.c
b/libopkg/file_util.c
index 155d73b52be1ac81d88ebfd851c50c98ede6f012..b1d793023154ff5f7da0f9ef76efc6601454b718 100644
(file)
--- a/
libopkg/file_util.c
+++ b/
libopkg/file_util.c
@@
-241,7
+241,7
@@
char *checksum_bin2hex(const char *src, size_t len)
'c', 'd', 'e', 'f'
};
- if (len > 32)
+ if (
!s ||
len > 32)
return NULL;
for (p = buf; len > 0; s++, len--) {
@@
-261,6
+261,11
@@
char *checksum_hex2bin(const char *src, size_t *len)
const unsigned char *s = (unsigned char *)src;
static unsigned char buf[32];
+ if (!src) {
+ *len = 0;
+ return NULL;
+ }
+
while (isspace(*src))
src++;