diff options
author | Arjun Shankar <arjun@redhat.com> | 2020-07-07 20:31:48 +0200 |
---|---|---|
committer | Arjun Shankar <arjun@redhat.com> | 2020-07-07 20:34:07 +0200 |
commit | 91927b7c76437db860cd86a7714476b56bb39d07 (patch) | |
tree | febc3201dd995bb8324b4712a31fef6d1bea388a /iconv/gconv_int.h | |
parent | 94d9c76e4acc798894ea23d9ac049ce7ce995ec0 (diff) | |
download | glibc-91927b7c76437db860cd86a7714476b56bb39d07.tar.gz glibc-91927b7c76437db860cd86a7714476b56bb39d07.tar.xz glibc-91927b7c76437db860cd86a7714476b56bb39d07.zip |
Rewrite iconv option parsing [BZ #19519]
This commit replaces string manipulation during `iconv_open' and iconv_prog option parsing with a structured, flag based conversion specification. In doing so, it alters the internal `__gconv_open' interface and accordingly adjusts its uses. This change fixes several hangs in the iconv program and therefore includes a new test to exercise iconv_prog options that originally led to these hangs. It also includes a new regression test for option handling in the iconv function. Reviewed-by: Florian Weimer <fweimer@redhat.com> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'iconv/gconv_int.h')
-rw-r--r-- | iconv/gconv_int.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h index fbaf12cee2..e86938dae7 100644 --- a/iconv/gconv_int.h +++ b/iconv/gconv_int.h @@ -75,6 +75,15 @@ struct gconv_module }; +/* The specification of the conversion that needs to be performed. */ +struct gconv_spec +{ + char *fromcode; + char *tocode; + bool translit; + bool ignore; +}; + /* Flags for `gconv_open'. */ enum { @@ -136,10 +145,12 @@ __libc_lock_define (extern, __gconv_lock attribute_hidden) }) -/* Return in *HANDLE decriptor for transformation from FROMSET to TOSET. */ -extern int __gconv_open (const char *toset, const char *fromset, - __gconv_t *handle, int flags) - attribute_hidden; +/* Return in *HANDLE, a decriptor for the transformation. The function expects + the specification of the transformation in the structure pointed to by + CONV_SPEC. It only reads *CONV_SPEC and does not take ownership of it. */ +extern int __gconv_open (struct gconv_spec *conv_spec, + __gconv_t *handle, int flags); +libc_hidden_proto (__gconv_open) /* Free resources associated with transformation descriptor CD. */ extern int __gconv_close (__gconv_t cd) |