Skip to content

Commit

Permalink
Merge branch 'master' into release-1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
mrclksr committed Jan 19, 2021
2 parents e7c5fc4 + fc8d387 commit 8c49866
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion dsbmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <libusb20.h>
#include <libutil.h>
#include <limits.h>
#include <locale.h>
#include <login_cap.h>
#include <paths.h>
#include <pthread.h>
Expand Down Expand Up @@ -1634,8 +1635,10 @@ ssystem(uid_t uid, const char *cmd)
static int
set_msdosfs_locale(const char *locale, struct iovec **iov, size_t *iovlen)
{
char *prev_locale;
const char *cs;

prev_locale = setlocale(LC_CTYPE, NULL);
if (modfind("msdosfs_iconv") == -1) {
if (errno != ENOENT) {
logprint("modfind(msdosfs_iconv) failed.");
Expand All @@ -1650,17 +1653,25 @@ set_msdosfs_locale(const char *locale, struct iovec **iov, size_t *iovlen)
logprintx("Invalid locale string '%s'", locale);
return (-1);
}
if (setlocale(LC_CTYPE, locale) == NULL)
die("setlocale(%s)", locale);
locale = kiconv_quirkcs(cs + 1, KICONV_VENDOR_MICSFT);
if (kiconv_add_xlat16_cspairs(ENCODING_UNICODE, locale) != 0 &&
errno != EEXIST)
die("kiconv_add_xlat16_cspairs(ENCODING_UNICODE)");
if (kiconv_add_xlat16_cspair(locale, locale,
KICONV_FROM_UPPER | KICONV_LOWER) != 0) {
logprint("kiconv_add_xlat16_cspair()");
if (prev_locale != NULL)
setlocale(LC_CTYPE, prev_locale);
return (-1);
}
extend_iovec(iov, iovlen, "cs_win", ENCODING_UNICODE);
extend_iovec(iov, iovlen, "cs_local", locale);
extend_iovec(iov, iovlen, "cs_dos", locale);
extend_iovec(iov, iovlen, "kiconv", "");

if (prev_locale != NULL)
setlocale(LC_CTYPE, prev_locale);
return (0);
}

Expand Down

0 comments on commit 8c49866

Please sign in to comment.