summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix von Leitner <felix-libowfat@fefe.de>2017-07-30 12:46:21 +0000
committerFelix von Leitner <felix-libowfat@fefe.de>2017-07-30 12:46:21 +0000
commit4310a56aeb492d748da93bca17171fdba9c3887a (patch)
tree174f2d908835b59ca1d96553234834f3043dcc30
parentfdb61c53015c07995ebcef6be01eed1b4bce581c (diff)
downloadlibowfat-4310a56aeb492d748da93bca17171fdba9c3887a.tar.gz
libowfat-4310a56aeb492d748da93bca17171fdba9c3887a.zip
don't write one more byte in error case
-rw-r--r--textcode/scan_ldapescape.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/textcode/scan_ldapescape.c b/textcode/scan_ldapescape.c
index 464abf7..fed16dd 100644
--- a/textcode/scan_ldapescape.c
+++ b/textcode/scan_ldapescape.c
@@ -7,12 +7,13 @@ size_t scan_ldapescape(const char *src,char *dest,size_t *destlen) {
size_t written=0,i;
for (i=0; s[i]; ++i) {
if (s[i]=='\\') {
+ unsigned char c;
int j=scan_fromhex(s[i+1]);
if (j<0) break;
- if (dest) dest[written]=j<<4;
+ c=j<<4;
j=scan_fromhex(s[i+2]);
if (j<0) break;
- if (dest) dest[written]|=j;
+ if (dest) dest[written]=c|j;
i+=2;
} else {
if (dest) dest[written]=s[i];