From: miker Date: Mon, 27 Nov 2006 17:27:22 +0000 (+0000) Subject: off-by-one ... arg X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d46559c55af94ca85a916e2ccc1a402465ad57dd;p=opensrf%2Fbjwebb.git off-by-one ... arg git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@803 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/utils/utils.c b/src/utils/utils.c index ffe738e..3c7a2d6 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -254,7 +254,7 @@ int buffer_add_char(growing_buffer* gb, char c) { char* uescape( const char* string, int size, int full_escape ) { growing_buffer* buf = buffer_init(size + 64); - int clen = 1; + int clen = 0; int idx = 0; unsigned long int c = 0x0; @@ -268,19 +268,19 @@ char* uescape( const char* string, int size, int full_escape ) { clen = 1; if (((unsigned char)string[idx] & 0xF0) == 0xF0) { - clen = 4; + clen = 3; c = (unsigned char)string[idx] ^ 0xF0; } else if (((unsigned char)string[idx] & 0xE0) == 0xE0) { - clen = 3; + clen = 2; c = (unsigned char)string[idx] ^ 0xE0; } else if (((unsigned char)string[idx] & 0xC0) == 0xC0) { - clen = 2; + clen = 1; c = (unsigned char)string[idx] ^ 0xC0; } - for (;clen;--clen) { + for (;clen;clen--) { idx++; // look at the next byte c = (c << 6) | ((unsigned char)string[idx] & 0x3F); // add this byte worth