- In the libiconv module for ISO 2022 restore the original order of the
fields of a private struct such that variables of this type are initialised correctly. Fixes conversion from ISO 2022. Also do this in the BIG5 module to prevent similar errors in the future. - In the libiconv module for EUC-TW replace 2^cs with 1<<cs. Fixes conversion from EUC-TW. - Synchronise iconv code with NetBSD. In most cases this only updates the RCS id because the changes are already there or are NetBSD specific. + libc/iconv/citrus_csmapper.c: Add a comment. + libc/iconv/citrus_db_factory.c: Remove put16(). + libc/iconv/citrus_iconv.c: Return EINVAL on error. + libc/iconv/citrus_mapper.c: Return EINVAL on error. + libc/iconv/citrus_memstream.c: Fix type of a variable. + libc/iconv/citrus_prop.h: Sync definition of _CITRUS_PROP_HINT_END. + libc/iconv/citrus_stdenc.c: Return EINVAL on error. + libiconv_modules/mapper_std/citrus_mapper_std.c: Plug memory leak. Obtained from: NetBSD MFC after: 2 weeks
This commit is contained in:
parent
4ebc1ddf98
commit
9ca40936af
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=263986
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_bcs_strtol.c,v 1.2 2009/01/11 02:46:24 christos Exp $ */
|
/* $NetBSD: citrus_bcs_strtol.c,v 1.4 2013/04/26 21:20:47 joerg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2005 The DragonFly Project. All rights reserved.
|
* Copyright (c) 2005 The DragonFly Project. All rights reserved.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_bcs_strtoul.c,v 1.3 2009/01/11 02:46:24 christos Exp $ */
|
/* $NetBSD: citrus_bcs_strtoul.c,v 1.5 2013/04/26 21:20:48 joerg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2005 The DragonFly Project. All rights reserved.
|
* Copyright (c) 2005 The DragonFly Project. All rights reserved.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_csmapper.c,v 1.10 2009/01/11 02:46:24 christos Exp $ */
|
/* $NetBSD: citrus_csmapper.c,v 1.11 2011/11/20 07:43:52 tnozaki Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
@ -140,6 +140,7 @@ find_best_pivot_pvdb(const char *src, const char *dst, char *pivot,
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto quit3;
|
goto quit3;
|
||||||
if (_db_lookup_by_s(db3, dst, &r2, NULL) != 0)
|
if (_db_lookup_by_s(db3, dst, &r2, NULL) != 0)
|
||||||
|
/* don't break the loop, test all src/dst pairs. */
|
||||||
goto quit4;
|
goto quit4;
|
||||||
/* r2: norm among pivot and dst */
|
/* r2: norm among pivot and dst */
|
||||||
ret = get32(&r2, &val32);
|
ret = get32(&r2, &val32);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_csmapper.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */
|
/* $NetBSD: citrus_csmapper.h,v 1.3 2013/06/24 17:28:35 joerg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_db_factory.c,v 1.9 2008/02/09 14:56:20 junyoung Exp $ */
|
/* $NetBSD: citrus_db_factory.c,v 1.10 2013/09/14 13:05:51 joerg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
@ -227,15 +227,6 @@ put8(struct _region *r, size_t *rofs, uint8_t val)
|
|||||||
*rofs += 1;
|
*rofs += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void
|
|
||||||
put16(struct _region *r, size_t *rofs, uint16_t val)
|
|
||||||
{
|
|
||||||
|
|
||||||
val = htons(val);
|
|
||||||
memcpy(_region_offset(r, *rofs), &val, 2);
|
|
||||||
*rofs += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline void
|
static __inline void
|
||||||
put32(struct _region *r, size_t *rofs, uint32_t val)
|
put32(struct _region *r, size_t *rofs, uint32_t val)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_iconv.c,v 1.7 2008/07/25 14:05:25 christos Exp $ */
|
/* $NetBSD: citrus_iconv.c,v 1.10 2011/11/19 18:34:21 tnozaki Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
@ -169,8 +169,10 @@ open_shared(struct _citrus_iconv_shared * __restrict * __restrict rci,
|
|||||||
ci->ci_ops->io_uninit_shared == NULL ||
|
ci->ci_ops->io_uninit_shared == NULL ||
|
||||||
ci->ci_ops->io_init_context == NULL ||
|
ci->ci_ops->io_init_context == NULL ||
|
||||||
ci->ci_ops->io_uninit_context == NULL ||
|
ci->ci_ops->io_uninit_context == NULL ||
|
||||||
ci->ci_ops->io_convert == NULL)
|
ci->ci_ops->io_convert == NULL) {
|
||||||
|
ret = EINVAL;
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* initialize the converter */
|
/* initialize the converter */
|
||||||
ret = (*ci->ci_ops->io_init_shared)(ci, src, dst);
|
ret = (*ci->ci_ops->io_init_shared)(ci, src, dst);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_lookup.c,v 1.6 2009/02/03 04:58:38 lukem Exp $ */
|
/* $NetBSD: citrus_lookup.c,v 1.7 2012/05/04 16:45:05 joerg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_mapper.c,v 1.7 2008/07/25 14:05:25 christos Exp $ */
|
/* $NetBSD: citrus_mapper.c,v 1.10 2012/06/08 07:49:42 martin Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
@ -244,8 +244,10 @@ mapper_open(struct _citrus_mapper_area *__restrict ma,
|
|||||||
if (!cm->cm_ops->mo_init ||
|
if (!cm->cm_ops->mo_init ||
|
||||||
!cm->cm_ops->mo_uninit ||
|
!cm->cm_ops->mo_uninit ||
|
||||||
!cm->cm_ops->mo_convert ||
|
!cm->cm_ops->mo_convert ||
|
||||||
!cm->cm_ops->mo_init_state)
|
!cm->cm_ops->mo_init_state) {
|
||||||
|
ret = EINVAL;
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* allocate traits structure */
|
/* allocate traits structure */
|
||||||
cm->cm_traits = malloc(sizeof(*cm->cm_traits));
|
cm->cm_traits = malloc(sizeof(*cm->cm_traits));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_memstream.c,v 1.4 2009/02/03 05:02:12 lukem Exp $ */
|
/* $NetBSD: citrus_memstream.c,v 1.5 2012/03/13 21:13:31 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
@ -44,8 +44,7 @@ _citrus_memory_stream_getln(struct _citrus_memory_stream * __restrict ms,
|
|||||||
size_t * __restrict rlen)
|
size_t * __restrict rlen)
|
||||||
{
|
{
|
||||||
const uint8_t *h, *p;
|
const uint8_t *h, *p;
|
||||||
size_t ret;
|
size_t i, ret;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (ms->ms_pos>=_region_size(&ms->ms_region))
|
if (ms->ms_pos>=_region_size(&ms->ms_region))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_mmap.c,v 1.3 2005/01/19 00:52:37 mycroft Exp $ */
|
/* $NetBSD: citrus_mmap.c,v 1.4 2011/10/15 23:00:01 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_prop.c,v 1.3 2006/11/22 23:47:21 tnozaki Exp $ */
|
/* $NetBSD: citrus_prop.c,v 1.4 2011/03/30 08:22:01 jruoho Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2006 Citrus Project,
|
* Copyright (c)2006 Citrus Project,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_prop.h,v 1.3 2006/11/23 13:59:03 tnozaki Exp $ */
|
/* $NetBSD: citrus_prop.h,v 1.5 2011/05/23 14:52:32 joerg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2006 Citrus Project,
|
* Copyright (c)2006 Citrus Project,
|
||||||
@ -82,7 +82,7 @@ struct _citrus_prop_hint_t {
|
|||||||
#define _CITRUS_PROP_HINT_NUM(name, cb) \
|
#define _CITRUS_PROP_HINT_NUM(name, cb) \
|
||||||
{ name, _CITRUS_PROP_NUM, { .num = { cb } } }
|
{ name, _CITRUS_PROP_NUM, { .num = { cb } } }
|
||||||
#define _CITRUS_PROP_HINT_END \
|
#define _CITRUS_PROP_HINT_END \
|
||||||
{ NULL, _CITRUS_PROP_NUM, { .num = { 0 } } }
|
{ .name = NULL }
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
int _citrus_prop_parse_variable(const _citrus_prop_hint_t * __restrict,
|
int _citrus_prop_parse_variable(const _citrus_prop_hint_t * __restrict,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_stdenc.c,v 1.3 2005/10/29 18:02:04 tshiozak Exp $ */
|
/* $NetBSD: citrus_stdenc.c,v 1.4 2011/11/19 18:39:58 tnozaki Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
@ -102,8 +102,10 @@ _citrus_stdenc_open(struct _citrus_stdenc * __restrict * __restrict rce,
|
|||||||
ce->ce_ops->eo_cstomb == NULL ||
|
ce->ce_ops->eo_cstomb == NULL ||
|
||||||
ce->ce_ops->eo_mbtowc == NULL ||
|
ce->ce_ops->eo_mbtowc == NULL ||
|
||||||
ce->ce_ops->eo_wctomb == NULL ||
|
ce->ce_ops->eo_wctomb == NULL ||
|
||||||
ce->ce_ops->eo_get_state_desc == NULL)
|
ce->ce_ops->eo_get_state_desc == NULL) {
|
||||||
|
ret = EINVAL;
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
|
|
||||||
/* allocate traits */
|
/* allocate traits */
|
||||||
ce->ce_traits = malloc(sizeof(*ce->ce_traits));
|
ce->ce_traits = malloc(sizeof(*ce->ce_traits));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_big5.c,v 1.12 2008/06/14 16:01:07 tnozaki Exp $ */
|
/* $NetBSD: citrus_big5.c,v 1.13 2011/05/23 14:53:46 joerg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2002, 2006 Citrus Project,
|
* Copyright (c)2002, 2006 Citrus Project,
|
||||||
@ -92,8 +92,8 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct _BIG5Exclude {
|
typedef struct _BIG5Exclude {
|
||||||
TAILQ_ENTRY(_BIG5Exclude) entry;
|
TAILQ_ENTRY(_BIG5Exclude) entry;
|
||||||
wint_t end;
|
|
||||||
wint_t start;
|
wint_t start;
|
||||||
|
wint_t end;
|
||||||
} _BIG5Exclude;
|
} _BIG5Exclude;
|
||||||
|
|
||||||
typedef TAILQ_HEAD(_BIG5ExcludeList, _BIG5Exclude) _BIG5ExcludeList;
|
typedef TAILQ_HEAD(_BIG5ExcludeList, _BIG5Exclude) _BIG5ExcludeList;
|
||||||
@ -358,7 +358,7 @@ _citrus_BIG5_wcrtomb_priv(_BIG5EncodingInfo * __restrict ei,
|
|||||||
size_t n, wchar_t wc, _BIG5State * __restrict psenc __unused,
|
size_t n, wchar_t wc, _BIG5State * __restrict psenc __unused,
|
||||||
size_t * __restrict nresult)
|
size_t * __restrict nresult)
|
||||||
{
|
{
|
||||||
unsigned char l;
|
size_t l;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* check invalid sequence */
|
/* check invalid sequence */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_dechanyu.c,v 1.3 2008/06/14 16:01:07 tnozaki Exp $ */
|
/* $NetBSD: citrus_dechanyu.c,v 1.4 2011/11/19 18:20:13 tnozaki Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2007 Citrus Project,
|
* Copyright (c)2007 Citrus Project,
|
||||||
|
@ -119,7 +119,7 @@ _citrus_EUCTW_count(int cs)
|
|||||||
case 1:
|
case 1:
|
||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
case 2:
|
case 2:
|
||||||
return (2^cs);
|
return (1 << cs);
|
||||||
case 3:
|
case 3:
|
||||||
abort();
|
abort();
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_iso2022.c,v 1.19 2008/06/14 16:01:07 tnozaki Exp $ */
|
/* $NetBSD: citrus_iso2022.c,v 1.20 2010/12/07 22:01:45 joerg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)1999, 2002 Citrus Project,
|
* Copyright (c)1999, 2002 Citrus Project,
|
||||||
@ -78,9 +78,9 @@
|
|||||||
#define CS96MULTI (3U)
|
#define CS96MULTI (3U)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned char interm;
|
|
||||||
unsigned char final;
|
|
||||||
unsigned char type;
|
unsigned char type;
|
||||||
|
unsigned char final;
|
||||||
|
unsigned char interm;
|
||||||
unsigned char vers;
|
unsigned char vers;
|
||||||
} _ISO2022Charset;
|
} _ISO2022Charset;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_ues.c,v 1.1 2006/11/13 15:16:31 tnozaki Exp $ */
|
/* $NetBSD: citrus_ues.c,v 1.3 2012/02/12 13:51:29 wiz Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2006 Citrus Project,
|
* Copyright (c)2006 Citrus Project,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_viqr.c,v 1.4 2008/06/14 16:01:08 tnozaki Exp $ */
|
/* $NetBSD: citrus_viqr.c,v 1.5 2011/11/19 18:20:13 tnozaki Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2006 Citrus Project,
|
* Copyright (c)2006 Citrus Project,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_iconv_none.c,v 1.2 2003/07/01 09:42:16 tshiozak Exp $ */
|
/* $NetBSD: citrus_iconv_none.c,v 1.3 2011/05/23 14:45:44 joerg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_iconv_std.c,v 1.15 2006/11/13 19:08:19 tnozaki Exp $ */
|
/* $NetBSD: citrus_iconv_std.c,v 1.16 2012/02/12 13:51:29 wiz Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003 Citrus Project,
|
* Copyright (c)2003 Citrus Project,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $NetBSD: citrus_mapper_std.c,v 1.8 2006/09/11 13:06:33 tnozaki Exp $ */
|
/* $NetBSD: citrus_mapper_std.c,v 1.10 2011/11/19 18:48:39 tnozaki Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c)2003, 2006 Citrus Project,
|
* Copyright (c)2003, 2006 Citrus Project,
|
||||||
@ -174,8 +174,11 @@ rowcol_parse_variable_compat(struct _citrus_mapper_std_rowcol *rc,
|
|||||||
n = be32toh(rcx->rcx_src_row_end);
|
n = be32toh(rcx->rcx_src_row_end);
|
||||||
if (m + n > 0) {
|
if (m + n > 0) {
|
||||||
ret = set_linear_zone(lz, m, n);
|
ret = set_linear_zone(lz, m, n);
|
||||||
if (ret != 0)
|
if (ret != 0) {
|
||||||
|
free(rc->rc_src_rowcol);
|
||||||
|
rc->rc_src_rowcol = NULL;
|
||||||
return (ret);
|
return (ret);
|
||||||
|
}
|
||||||
++rc->rc_src_rowcol_len, ++lz;
|
++rc->rc_src_rowcol_len, ++lz;
|
||||||
}
|
}
|
||||||
m = be32toh(rcx->rcx_src_col_begin);
|
m = be32toh(rcx->rcx_src_col_begin);
|
||||||
|
Loading…
Reference in New Issue
Block a user