don't write one more byte in error case

master
leitner 7 years ago
parent 527e2e7c5b
commit 8d449d442b

@ -7,12 +7,13 @@ size_t scan_ldapescape(const char *src,char *dest,size_t *destlen) {
size_t written=0,i; size_t written=0,i;
for (i=0; s[i]; ++i) { for (i=0; s[i]; ++i) {
if (s[i]=='\\') { if (s[i]=='\\') {
unsigned char c;
int j=scan_fromhex(s[i+1]); int j=scan_fromhex(s[i+1]);
if (j<0) break; if (j<0) break;
if (dest) dest[written]=j<<4; c=j<<4;
j=scan_fromhex(s[i+2]); j=scan_fromhex(s[i+2]);
if (j<0) break; if (j<0) break;
if (dest) dest[written]|=j; if (dest) dest[written]=c|j;
i+=2; i+=2;
} else { } else {
if (dest) dest[written]=s[i]; if (dest) dest[written]=s[i];

Loading…
Cancel
Save