Date: Mon, 24 Feb 2014 13:33:21 +0000 (UTC) From: Tijl Coosemans <tijl@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262441 - in head/lib: libc/iconv libiconv_modules/BIG5 libiconv_modules/HZ Message-ID: <201402241333.s1ODXLUN032474@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tijl Date: Mon Feb 24 13:33:20 2014 New Revision: 262441 URL: http://svnweb.freebsd.org/changeset/base/262441 Log: Consistently pass around context information using a simple pointer. This fixes some dereferencing bugs in Chinese character set conversions. PR: 185964 MFC after: 5 days Modified: head/lib/libc/iconv/citrus_prop.c head/lib/libc/iconv/citrus_prop.h head/lib/libiconv_modules/BIG5/citrus_big5.c head/lib/libiconv_modules/HZ/citrus_hz.c Modified: head/lib/libc/iconv/citrus_prop.c ============================================================================== --- head/lib/libc/iconv/citrus_prop.c Mon Feb 24 12:45:03 2014 (r262440) +++ head/lib/libc/iconv/citrus_prop.c Mon Feb 24 13:33:20 2014 (r262441) @@ -339,7 +339,7 @@ name_found: static int _citrus_prop_parse_element(struct _memstream * __restrict ms, - const _citrus_prop_hint_t * __restrict hints, void ** __restrict context) + const _citrus_prop_hint_t * __restrict hints, void * __restrict context) { int ch, errnum; #define _CITRUS_PROP_HINT_NAME_LEN_MAX 255 @@ -435,8 +435,7 @@ _citrus_prop_parse_variable(const _citru if (ch == EOF || ch == '\0') break; _memstream_ungetc(&ms, ch); - errnum = _citrus_prop_parse_element( - &ms, hints, (void ** __restrict)context); + errnum = _citrus_prop_parse_element(&ms, hints, context); if (errnum != 0) return (errnum); } Modified: head/lib/libc/iconv/citrus_prop.h ============================================================================== --- head/lib/libc/iconv/citrus_prop.h Mon Feb 24 12:45:03 2014 (r262440) +++ head/lib/libc/iconv/citrus_prop.h Mon Feb 24 13:33:20 2014 (r262441) @@ -42,7 +42,7 @@ typedef struct _citrus_prop_hint_t _citr #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; @@ -52,7 +52,7 @@ _CITRUS_PROP_CB0_T(str, const char *) #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; Modified: head/lib/libiconv_modules/BIG5/citrus_big5.c ============================================================================== --- head/lib/libiconv_modules/BIG5/citrus_big5.c Mon Feb 24 12:45:03 2014 (r262440) +++ head/lib/libiconv_modules/BIG5/citrus_big5.c Mon Feb 24 13:33:20 2014 (r262441) @@ -172,7 +172,7 @@ _citrus_BIG5_check_excludes(_BIG5Encodin } 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; @@ -191,7 +191,7 @@ _citrus_BIG5_fill_rowcol(void ** __restr static int /*ARGSUSED*/ -_citrus_BIG5_fill_excludes(void ** __restrict ctx, +_citrus_BIG5_fill_excludes(void * __restrict ctx, const char * __restrict s __unused, uint64_t start, uint64_t end) { _BIG5EncodingInfo *ei; @@ -237,7 +237,6 @@ static int _citrus_BIG5_encoding_module_init(_BIG5EncodingInfo * __restrict ei, const void * __restrict var, size_t lenvar) { - void *ctx = (void *)ei; const char *s; int err; @@ -259,9 +258,9 @@ _citrus_BIG5_encoding_module_init(_BIG5E } /* fallback Big5-1984, for backward compatibility. */ - _citrus_BIG5_fill_rowcol((void **)&ctx, "row", 0xA1, 0xFE); - _citrus_BIG5_fill_rowcol((void **)&ctx, "col", 0x40, 0x7E); - _citrus_BIG5_fill_rowcol((void **)&ctx, "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); } Modified: head/lib/libiconv_modules/HZ/citrus_hz.c ============================================================================== --- head/lib/libiconv_modules/HZ/citrus_hz.c Mon Feb 24 12:45:03 2014 (r262440) +++ head/lib/libiconv_modules/HZ/citrus_hz.c Mon Feb 24 13:33:20 2014 (r262441) @@ -505,12 +505,12 @@ _citrus_HZ_encoding_module_uninit(_HZEnc } static int -_citrus_HZ_parse_char(void **context, const char *name __unused, const char *s) +_citrus_HZ_parse_char(void *context, const char *name __unused, const char *s) { escape_t *escape; void **p; - p = (void **)*context; + p = (void **)context; escape = (escape_t *)p[0]; if (escape->ch != '\0') return (EINVAL); @@ -522,14 +522,14 @@ _citrus_HZ_parse_char(void **context, co } 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) { _HZEncodingInfo *ei; escape_t *escape; graphic_t *graphic; void **p; - p = (void **)*context; + p = (void **)context; escape = (escape_t *)p[0]; ei = (_HZEncodingInfo *)p[1]; graphic = malloc(sizeof(*graphic)); @@ -591,13 +591,13 @@ _CITRUS_PROP_HINT_END }; 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; void *p[2]; - ei = (_HZEncodingInfo *)*context; + ei = (_HZEncodingInfo *)context; escape = malloc(sizeof(*escape)); if (escape == NULL) return (EINVAL);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402241333.s1ODXLUN032474>