[pkg-opensc-commit] [opensc] 23/50: Detect premature end hexstring
Eric Dorland
eric at moszumanska.debian.org
Sat May 28 03:35:48 UTC 2016
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository opensc.
commit c63ba858e32950b975bc6817c4dd9276ceea8715
Author: Andreas Schwier <andreas.schwier at cardcontact.de>
Date: Mon Apr 18 14:07:43 2016 +0200
Detect premature end hexstring
---
src/libopensc/sc.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/libopensc/sc.c b/src/libopensc/sc.c
index 450508f..b378d55 100644
--- a/src/libopensc/sc.c
+++ b/src/libopensc/sc.c
@@ -53,7 +53,7 @@ int sc_hex_to_bin(const char *in, u8 *out, size_t *outlen)
size_t left, count = 0;
assert(in != NULL && out != NULL && outlen != NULL);
- left = *outlen;
+ left = *outlen;
while (*in != '\0') {
int byte = 0, nybbles = 2;
@@ -76,10 +76,15 @@ int sc_hex_to_bin(const char *in, u8 *out, size_t *outlen)
}
byte |= c;
}
+ // Detect premature end of string before byte is complete
+ if (!*in && nybbles >= 0) {
+ err = SC_ERROR_INVALID_ARGUMENTS;
+ break;
+ }
if (*in == ':' || *in == ' ')
in++;
if (left <= 0) {
- err = SC_ERROR_BUFFER_TOO_SMALL;
+ err = SC_ERROR_BUFFER_TOO_SMALL;
break;
}
out[count++] = (u8) byte;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/opensc.git
More information about the pkg-opensc-commit
mailing list