7155867 *proftpd* does not work in multibyte locale other than UTF-8 s11-sru S11SRU9_03
authorTomas Klacko <tomas.klacko@oracle.com>
Tue, 19 Jun 2012 02:04:06 -0700
branchs11-sru
changeset 2292 7fe16a6a2bde
parent 2291 b0bb4aa104b6
child 2293 b3ed7ecee31f
7155867 *proftpd* does not work in multibyte locale other than UTF-8
components/proftpd/patches/encode-bug3769.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/proftpd/patches/encode-bug3769.patch	Tue Jun 19 02:04:06 2012 -0700
@@ -0,0 +1,81 @@
+--- a/src/encode.c
++++ b/src/encode.c
[email protected]@ -194,10 +194,12 @@ int encode_init(void) {
+ 
+ char *pr_decode_str(pool *p, const char *in, size_t inlen, size_t *outlen) {
+ #ifdef HAVE_ICONV
+-  size_t inbuflen, outbuflen;
++  size_t inbuflen, outbuflen, outbufsz;
+   char *inbuf, outbuf[PR_TUNABLE_PATH_MAX*2], *res = NULL;
+ 
+-  if (!p || !in || !outlen) {
++  if (p == NULL ||
++      in == NULL ||
++      outlen == NULL) {
+     errno = EINVAL;
+     return NULL;
+   }
[email protected]@ -229,7 +231,11 @@ char *pr_decode_str(pool *p, const char *in, size_t inlen, size_t *outlen) {
+     return NULL;
+ 
+   *outlen = sizeof(outbuf) - outbuflen;
+-  res = pcalloc(p, *outlen);
++
++  /* We allocate one byte more, for a terminating NUL. */
++  outbufsz = sizeof(outbuf) - outbuflen + 1;
++  res = pcalloc(p, outbufsz);
++
+   memcpy(res, outbuf, *outlen);
+ 
+   return res;
[email protected]@ -242,10 +248,12 @@ char *pr_decode_str(pool *p, const char *in, size_t inlen, size_t *outlen) {
+ 
+ char *pr_encode_str(pool *p, const char *in, size_t inlen, size_t *outlen) {
+ #ifdef HAVE_ICONV
+-  size_t inbuflen, outbuflen;
++  size_t inbuflen, outbuflen, outbufsz;
+   char *inbuf, outbuf[PR_TUNABLE_PATH_MAX*2], *res;
+ 
+-  if (!p || !in || !outlen) {
++  if (p == NULL ||
++      in == NULL ||
++      outlen == NULL) {
+     errno = EINVAL;
+     return NULL;
+   }
[email protected]@ -277,7 +285,11 @@ char *pr_encode_str(pool *p, const char *in, size_t inlen, size_t *outlen) {
+     return NULL;
+ 
+   *outlen = sizeof(outbuf) - outbuflen;
+-  res = pcalloc(p, *outlen);
++
++  /* We allocate one byte more, for a terminating NUL. */
++  outbufsz = sizeof(outbuf) - outbuflen + 1;
++
++  res = pcalloc(p, outbufsz);
+   memcpy(res, outbuf, *outlen);
+ 
+   return res;
+diff --git a/src/fsio.c b/src/fsio.c
+index 40ef466..8bf5069 100644
+--- a/src/fsio.c
++++ b/src/fsio.c
[email protected]@ -2058,7 +2058,7 @@ char *pr_fs_decode_path(pool *p, const char *path) {
+     return (char *) path;
+   }
+ 
+-  res = pr_decode_str(p, path, strlen(path) + 1, &outlen);
++  res = pr_decode_str(p, path, strlen(path), &outlen);
+   if (!res) {
+     pr_trace_msg("encode", 1, "error decoding path '%s': %s", path,
+       strerror(errno));
[email protected]@ -2081,7 +2081,7 @@ char *pr_fs_encode_path(pool *p, const char *path) {
+     return (char *) path;
+   }
+ 
+-  res = pr_encode_str(p, path, strlen(path) + 1, &outlen);
++  res = pr_encode_str(p, path, strlen(path), &outlen);
+   if (!res) {
+     pr_trace_msg("encode", 1, "error encoding path '%s': %s", path,
+       strerror(errno));
+