author | Tomas Klacko <tomas.klacko@oracle.com> |
Tue, 19 Jun 2012 02:04:06 -0700 | |
branch | s11-sru |
changeset 2292 | 7fe16a6a2bde |
permissions | -rw-r--r-- |
2292
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
1 |
--- a/src/encode.c |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
2 |
+++ b/src/encode.c |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
3 |
@@ -194,10 +194,12 @@ int encode_init(void) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
4 |
|
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
5 |
char *pr_decode_str(pool *p, const char *in, size_t inlen, size_t *outlen) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
6 |
#ifdef HAVE_ICONV |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
7 |
- size_t inbuflen, outbuflen; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
8 |
+ size_t inbuflen, outbuflen, outbufsz; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
9 |
char *inbuf, outbuf[PR_TUNABLE_PATH_MAX*2], *res = NULL; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
10 |
|
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
11 |
- if (!p || !in || !outlen) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
12 |
+ if (p == NULL || |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
13 |
+ in == NULL || |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
14 |
+ outlen == NULL) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
15 |
errno = EINVAL; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
16 |
return NULL; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
17 |
} |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
18 |
@@ -229,7 +231,11 @@ char *pr_decode_str(pool *p, const char *in, size_t inlen, size_t *outlen) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
19 |
return NULL; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
20 |
|
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
21 |
*outlen = sizeof(outbuf) - outbuflen; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
22 |
- res = pcalloc(p, *outlen); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
23 |
+ |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
24 |
+ /* We allocate one byte more, for a terminating NUL. */ |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
25 |
+ outbufsz = sizeof(outbuf) - outbuflen + 1; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
26 |
+ res = pcalloc(p, outbufsz); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
27 |
+ |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
28 |
memcpy(res, outbuf, *outlen); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
29 |
|
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
30 |
return res; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
31 |
@@ -242,10 +248,12 @@ char *pr_decode_str(pool *p, const char *in, size_t inlen, size_t *outlen) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
32 |
|
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
33 |
char *pr_encode_str(pool *p, const char *in, size_t inlen, size_t *outlen) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
34 |
#ifdef HAVE_ICONV |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
35 |
- size_t inbuflen, outbuflen; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
36 |
+ size_t inbuflen, outbuflen, outbufsz; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
37 |
char *inbuf, outbuf[PR_TUNABLE_PATH_MAX*2], *res; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
38 |
|
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
39 |
- if (!p || !in || !outlen) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
40 |
+ if (p == NULL || |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
41 |
+ in == NULL || |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
42 |
+ outlen == NULL) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
43 |
errno = EINVAL; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
44 |
return NULL; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
45 |
} |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
46 |
@@ -277,7 +285,11 @@ char *pr_encode_str(pool *p, const char *in, size_t inlen, size_t *outlen) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
47 |
return NULL; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
48 |
|
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
49 |
*outlen = sizeof(outbuf) - outbuflen; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
50 |
- res = pcalloc(p, *outlen); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
51 |
+ |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
52 |
+ /* We allocate one byte more, for a terminating NUL. */ |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
53 |
+ outbufsz = sizeof(outbuf) - outbuflen + 1; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
54 |
+ |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
55 |
+ res = pcalloc(p, outbufsz); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
56 |
memcpy(res, outbuf, *outlen); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
57 |
|
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
58 |
return res; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
59 |
diff --git a/src/fsio.c b/src/fsio.c |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
60 |
index 40ef466..8bf5069 100644 |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
61 |
--- a/src/fsio.c |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
62 |
+++ b/src/fsio.c |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
63 |
@@ -2058,7 +2058,7 @@ char *pr_fs_decode_path(pool *p, const char *path) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
64 |
return (char *) path; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
65 |
} |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
66 |
|
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
67 |
- res = pr_decode_str(p, path, strlen(path) + 1, &outlen); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
68 |
+ res = pr_decode_str(p, path, strlen(path), &outlen); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
69 |
if (!res) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
70 |
pr_trace_msg("encode", 1, "error decoding path '%s': %s", path, |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
71 |
strerror(errno)); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
72 |
@@ -2081,7 +2081,7 @@ char *pr_fs_encode_path(pool *p, const char *path) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
73 |
return (char *) path; |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
74 |
} |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
75 |
|
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
76 |
- res = pr_encode_str(p, path, strlen(path) + 1, &outlen); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
77 |
+ res = pr_encode_str(p, path, strlen(path), &outlen); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
78 |
if (!res) { |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
79 |
pr_trace_msg("encode", 1, "error encoding path '%s': %s", path, |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
80 |
strerror(errno)); |
7fe16a6a2bde
7155867 *proftpd* does not work in multibyte locale other than UTF-8
Tomas Klacko <tomas.klacko@oracle.com>
parents:
diff
changeset
|
81 |