summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-02-07 22:20:35 +0100
committerGravatar waker <wakeroid@gmail.com>2011-02-07 22:20:35 +0100
commit38e883f1fbc97fc33a01af93cd0a82f971390b51 (patch)
tree5ee065eb2a69f4d19473a49de605bb5c4d4460dd
parent083e9b711cdd5f255e09dfb040a9fd93e97c1774 (diff)
fixed junklib utf8 validation
-rw-r--r--junklib.c6
-rw-r--r--utf8.c11
2 files changed, 8 insertions, 9 deletions
diff --git a/junklib.c b/junklib.c
index 635a2307..e8ea3b00 100644
--- a/junklib.c
+++ b/junklib.c
@@ -320,10 +320,10 @@ int ddb_iconv (const char *cs_out, const char *cs_in, char *out, int outlen, con
// to utf8 branch
if (!strcmp (cs_out, UTF8_STR)) {
if (!strcmp (cs_in, UTF8_STR)) {
- int valid = u8_valid (in, inlen, NULL);
+ memcpy (out, in, inlen);
+ out[inlen] = 0;
+ int valid = u8_valid (out, inlen, NULL);
if (valid) {
- memcpy (out, in, inlen);
- out[inlen] = 0;
len = inlen;
}
}
diff --git a/utf8.c b/utf8.c
index bb115e64..c303b9a1 100644
--- a/utf8.c
+++ b/utf8.c
@@ -590,14 +590,13 @@ int u8_valid (const char *str,
/* See that we covered the entire length if a length was
* passed in, or that we ended on a nul if not
*/
- if (max_len >= 0 &&
- p != (str + max_len))
+ if (max_len >= 0 && p != (str + max_len) && *p != 0) {
return 0;
- else if (max_len < 0 &&
- *p != '\0')
+ }
+ else if (max_len < 0 && *p != '\0') {
return 0;
- else
- return 1;
+ }
+ return 1;
}
#if 0