[vbox-dev] NetBSD patch 0002: Handle NetBSD specific iconv_open(3) behavior for empty codesets
Kamil Rytarowski
n54 at gmx.com
Sun Jul 10 14:44:17 UTC 2016
Handle NetBSD specific iconv_open(3) behavior for empty codesets
According to POSIX materials:
"Settings of fromcode and tocode and their permitted combinations
are implementation-defined."
-- http://pubs.opengroup.org/onlinepubs/009695399/functions/iconv_open.html
NetBSD doesn't allow empty strings to be passed to this function:
$ cat /tmp/test.c
#include <iconv.h>
#include <err.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
iconv_t h = iconv_open("", "UTF-8");
if (h == (iconv_t)-1)
err(EXIT_FAILURE, "iconv_open");
printf("OK!\n");
return 0;
}
$ gcc test.c -o test
$ ./test
test: iconv_open: Invalid argument
This patch is MIT-licensed.
Author: Kamil Rytarowski
-------------- next part --------------
Handle NetBSD specific iconv_open(3) behavior for empty codesets
According to POSIX materials:
"Settings of fromcode and tocode and their permitted combinations are
implementation-defined."
-- http://pubs.opengroup.org/onlinepubs/009695399/functions/iconv_open.html
NetBSD doesn't allow empty strings to be passed to this function:
$ cat /tmp/test.c
#include <iconv.h>
#include <err.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
iconv_t h = iconv_open("", "UTF-8");
if (h == (iconv_t)-1)
err(EXIT_FAILURE, "iconv_open");
printf("OK!\n");
return 0;
}
$ gcc test.c -o test
$ ./test
test: iconv_open: Invalid argument
This patch is MIT-licensed.
Author: Kamil Rytarowski
Index: src/VBox/Runtime/r3/posix/utf8-posix.cpp
===================================================================
--- src/VBox/Runtime/r3/posix/utf8-posix.cpp (wersja 62125)
+++ src/VBox/Runtime/r3/posix/utf8-posix.cpp (kopia robocza)
@@ -173,8 +173,8 @@
iconv_t hIconv = (iconv_t)*phIconv;
if (hIconv == (iconv_t)-1)
{
-#ifdef RT_OS_SOLARIS
- /* Solaris doesn't grok empty codeset strings, so help it find the current codeset. */
+#if defined(RT_OS_SOLARIS) || defined(RT_OS_NETBSD)
+ /* Some systems don't grok empty codeset strings, so help it find the current codeset. */
if (!*pszInputCS)
pszInputCS = rtStrGetLocaleCodeset();
if (!*pszOutputCS)
@@ -494,4 +494,3 @@
}
return rtStrConvertWrapper(pszString, cch, "", ppszString, 0, "UTF-8", 2, RTSTRICONV_LOCALE_TO_UTF8);
}
-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20160710/d5bb02b5/attachment.sig>
More information about the vbox-dev
mailing list