Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/citrus Fix our iconv version for the issues that ap...



details:   https://anonhg.NetBSD.org/src/rev/a93a63cf3232
branches:  trunk
changeset: 330147:a93a63cf3232
user:      spz <spz%NetBSD.org@localhost>
date:      Tue Jun 24 22:24:18 2014 +0000

description:
Fix our iconv version for the issues that apply to us from CVE-2014-3951
(which are the:
- Consistently pass around context information using a simple pointer.
  This fixes some dereferencing bugs in Chinese character set conversions.
- Fix Simplified Chinese character set conversions by switching around the
  fields of an internal struct so it corresponds with the way variables of
  this type are initialised.
part)
Patch taken from FreeBSD and mutilated to fit.
FreeBSD credits: Manuel Mausz (reporter), Tijl Coosemans (report handler)

diffstat:

 lib/libc/citrus/citrus_prop.c         |   9 ++++-----
 lib/libc/citrus/citrus_prop.h         |   6 +++---
 lib/libc/citrus/modules/citrus_big5.c |  22 +++++++++++-----------
 lib/libc/citrus/modules/citrus_hz.c   |  16 ++++++++--------
 4 files changed, 26 insertions(+), 27 deletions(-)

diffs (210 lines):

diff -r 50f73cb6f488 -r a93a63cf3232 lib/libc/citrus/citrus_prop.c
--- a/lib/libc/citrus/citrus_prop.c     Tue Jun 24 22:19:36 2014 +0000
+++ b/lib/libc/citrus/citrus_prop.c     Tue Jun 24 22:24:18 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_prop.c,v 1.4 2011/03/30 08:22:01 jruoho Exp $ */
+/* $NetBSD: citrus_prop.c,v 1.5 2014/06/24 22:24:18 spz Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_prop.c,v 1.4 2011/03/30 08:22:01 jruoho Exp $");
+__RCSID("$NetBSD: citrus_prop.c,v 1.5 2014/06/24 22:24:18 spz Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <assert.h>
@@ -350,7 +350,7 @@
 static int
 _citrus_prop_parse_element(struct _memstream * __restrict ms,
        const _citrus_prop_hint_t * __restrict hints,
-       void ** __restrict context)
+       void * __restrict context)
 {
        int ch, errnum;
 #define _CITRUS_PROP_HINT_NAME_LEN_MAX 255
@@ -459,8 +459,7 @@
                if (ch == EOF || ch == '\0')
                        break;
                _memstream_ungetc(&ms, ch);
-               errnum = _citrus_prop_parse_element(
-                   &ms, hints, (void **)&context);
+               errnum = _citrus_prop_parse_element(&ms, hints, context);
                if (errnum != 0)
                        return errnum;
        }
diff -r 50f73cb6f488 -r a93a63cf3232 lib/libc/citrus/citrus_prop.h
--- a/lib/libc/citrus/citrus_prop.h     Tue Jun 24 22:19:36 2014 +0000
+++ b/lib/libc/citrus/citrus_prop.h     Tue Jun 24 22:24:18 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_prop.h,v 1.5 2011/05/23 14:52:32 joerg Exp $ */
+/* $NetBSD: citrus_prop.h,v 1.6 2014/06/24 22:24:18 spz Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,
@@ -41,7 +41,7 @@
 
 #define _CITRUS_PROP_CB0_T(_func_, _type_) \
 typedef int (*_citrus_prop_##_func_##_cb_func_t) \
-       (void ** __restrict, const char *, _type_); \
+       (void * __restrict, const char *, _type_); \
 typedef struct { \
        _citrus_prop_##_func_##_cb_func_t func; \
 } _citrus_prop_##_func_##_cb_t;
@@ -51,7 +51,7 @@
 
 #define _CITRUS_PROP_CB1_T(_func_, _type_) \
 typedef int (*_citrus_prop_##_func_##_cb_func_t) \
-       (void ** __restrict, const char *, _type_, _type_); \
+       (void * __restrict, const char *, _type_, _type_); \
 typedef struct { \
        _citrus_prop_##_func_##_cb_func_t func; \
 } _citrus_prop_##_func_##_cb_t;
diff -r 50f73cb6f488 -r a93a63cf3232 lib/libc/citrus/modules/citrus_big5.c
--- a/lib/libc/citrus/modules/citrus_big5.c     Tue Jun 24 22:19:36 2014 +0000
+++ b/lib/libc/citrus/modules/citrus_big5.c     Tue Jun 24 22:24:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: citrus_big5.c,v 1.14 2013/05/28 16:57:56 joerg Exp $   */
+/*     $NetBSD: citrus_big5.c,v 1.15 2014/06/24 22:24:18 spz Exp $     */
 
 /*-
  * Copyright (c)2002, 2006 Citrus Project,
@@ -60,7 +60,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_big5.c,v 1.14 2013/05/28 16:57:56 joerg Exp $");
+__RCSID("$NetBSD: citrus_big5.c,v 1.15 2014/06/24 22:24:18 spz Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/queue.h>
@@ -192,18 +192,18 @@
 }
 
 static int
-_citrus_BIG5_fill_rowcol(void ** __restrict ctx, const char * __restrict s,
+_citrus_BIG5_fill_rowcol(void * __restrict ctx, const char * __restrict s,
        uint64_t start, uint64_t end)
 {
        _BIG5EncodingInfo *ei;
        int i;
        uint64_t n;
 
-       _DIAGASSERT(ctx != NULL && *ctx != NULL);
+       _DIAGASSERT(ctx != NULL);
 
        if (start > 0xFF || end > 0xFF)
                return EINVAL;
-       ei = (_BIG5EncodingInfo *)*ctx;
+       ei = (_BIG5EncodingInfo *)ctx;
        i = strcmp("row", s) ? 1 : 0;
        i = 1 << i;
        for (n = start; n <= end; ++n)
@@ -213,17 +213,17 @@
 
 static int
 /*ARGSUSED*/
-_citrus_BIG5_fill_excludes(void ** __restrict ctx, const char * __restrict s,
+_citrus_BIG5_fill_excludes(void * __restrict ctx, const char * __restrict s,
        uint64_t start, uint64_t end)
 {
        _BIG5EncodingInfo *ei;
        _BIG5Exclude *exclude;
 
-       _DIAGASSERT(ctx != NULL && *ctx != NULL);
+       _DIAGASSERT(ctx != NULL);
 
        if (start > 0xFFFF || end > 0xFFFF)
                return EINVAL;
-       ei = (_BIG5EncodingInfo *)*ctx;
+       ei = (_BIG5EncodingInfo *)ctx;
        exclude = TAILQ_LAST(&ei->excludes, _BIG5ExcludeList);
        if (exclude != NULL && (wint_t)start <= exclude->end)
                return EINVAL;
@@ -286,9 +286,9 @@
        }
 
        /* fallback Big5-1984, for backward compatibility. */
-       _citrus_BIG5_fill_rowcol((void **)&ei, "row", 0xA1, 0xFE);
-       _citrus_BIG5_fill_rowcol((void **)&ei, "col", 0x40, 0x7E);
-       _citrus_BIG5_fill_rowcol((void **)&ei, "col", 0xA1, 0xFE);
+       _citrus_BIG5_fill_rowcol(ei, "row", 0xA1, 0xFE);
+       _citrus_BIG5_fill_rowcol(ei, "col", 0x40, 0x7E);
+       _citrus_BIG5_fill_rowcol(ei, "col", 0xA1, 0xFE);
 
        return 0;
 }
diff -r 50f73cb6f488 -r a93a63cf3232 lib/libc/citrus/modules/citrus_hz.c
--- a/lib/libc/citrus/modules/citrus_hz.c       Tue Jun 24 22:19:36 2014 +0000
+++ b/lib/libc/citrus/modules/citrus_hz.c       Tue Jun 24 22:24:18 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_hz.c,v 1.3 2013/05/28 16:57:56 joerg Exp $ */
+/* $NetBSD: citrus_hz.c,v 1.4 2014/06/24 22:24:18 spz Exp $ */
 
 /*-
  * Copyright (c)2004, 2006 Citrus Project,
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_hz.c,v 1.3 2013/05/28 16:57:56 joerg Exp $");
+__RCSID("$NetBSD: citrus_hz.c,v 1.4 2014/06/24 22:24:18 spz Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/queue.h>
@@ -559,7 +559,7 @@
 }
 
 static int
-_citrus_HZ_parse_char(void **context, const char *name, const char *s)
+_citrus_HZ_parse_char(void *context, const char *name, const char *s)
 {
        void **p;
        escape_t *escape;
@@ -568,7 +568,7 @@
        _DIAGASSERT(name != NULL);
        _DIAGASSERT(s != NULL);
 
-       p = (void **)*context;
+       p = (void **)context;
        escape = (escape_t *)p[0];
        if (escape->ch != '\0')
                return EINVAL;
@@ -580,7 +580,7 @@
 }
 
 static int
-_citrus_HZ_parse_graphic(void **context, const char *name, const char *s)
+_citrus_HZ_parse_graphic(void *context, const char *name, const char *s)
 {
        void **p;
        _HZEncodingInfo *ei;
@@ -591,7 +591,7 @@
        _DIAGASSERT(name != NULL);
        _DIAGASSERT(s != NULL);
 
-       p = (void **)*context;
+       p = (void **)context;
        escape = (escape_t *)p[0];
        ei = (_HZEncodingInfo *)p[1];
        graphic = malloc(sizeof(*graphic));
@@ -654,7 +654,7 @@
 };
 
 static int
-_citrus_HZ_parse_escape(void **context, const char *name, const char *s)
+_citrus_HZ_parse_escape(void *context, const char *name, const char *s)
 {
        _HZEncodingInfo *ei;
        escape_t *escape;
@@ -664,7 +664,7 @@
        _DIAGASSERT(name != NULL);
        _DIAGASSERT(s != NULL);
 
-       ei = (_HZEncodingInfo *)*context;
+       ei = (_HZEncodingInfo *)context;
        escape = malloc(sizeof(*escape));
        if (escape == NULL)
                return EINVAL;



Home | Main Index | Thread Index | Old Index