7155867 *proftpd* does not work in multibyte locale other than UTF-8
authorTomas Klacko <tomas.klacko@oracle.com>
Wed, 16 May 2012 01:39:44 -0700
changeset 816 5df727abb287
parent 815 e17805629856
child 817 f45ca7242301
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	Wed May 16 01:39:44 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));
+