summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/lib/util_unistr.c22
-rw-r--r--source3/rpc_parse/parse_spoolss.c8
3 files changed, 27 insertions, 4 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 7001c67f98..e0db05e7bf 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -517,6 +517,7 @@ smb_ucs2_t *multibyte_to_unicode(smb_ucs2_t *dst, const char *src,
char *unicode_to_unix(char *dst, const smb_ucs2_t *src, size_t dst_len);
smb_ucs2_t *unix_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len);
char *unicode_to_dos(char *dst, const smb_ucs2_t *src, size_t dst_len);
+size_t unicode_to_dos_char(char *dst, const smb_ucs2_t src);
smb_ucs2_t *dos_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len);
size_t strlen_w(const smb_ucs2_t *src);
smb_ucs2_t *safe_strcpy_w(smb_ucs2_t *dest,const smb_ucs2_t *src, size_t maxlength);
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index 4a66adc0fd..c28ef44934 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -780,6 +780,28 @@ char *unicode_to_dos(char *dst, const smb_ucs2_t *src, size_t dst_len)
}
/*******************************************************************
+ Convert a single UNICODE character to DOS codepage. Returns the
+ number of bytes in the DOS codepage character.
+********************************************************************/
+
+size_t unicode_to_dos_char(char *dst, const smb_ucs2_t src)
+{
+ smb_ucs2_t val = ucs2_to_doscp[src];
+ if(val < 256) {
+ *dst = (char)val;
+ return (size_t)1;
+ }
+ /*
+ * A 2 byte value is always written as
+ * high/low into the buffer stream.
+ */
+
+ dst[0] = (char)((val >> 8) & 0xff);
+ dst[1] = (char)(val & 0xff);
+ return (size_t)2;
+}
+
+/*******************************************************************
Convert a DOS string to UNICODE format. Note that the 'dst' is in
native byte order, not little endian. Always zero terminates.
This function may be replaced if the DOS codepage format is a
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 62dbc16277..987ae42ff4 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -3718,12 +3718,12 @@ BOOL spool_io_printer_driver_info_level_6(char *desc, SPOOL_PRINTER_DRIVER_INFO_
convert a buffer of UNICODE strings null terminated
the buffer is terminated by a NULL
- convert to an ascii array (null terminated)
+ convert to an dos codepage array (null terminated)
dynamically allocate memory
********************************************************************/
-BOOL uniarray_2_ascarray(BUFFER5 *buf5, char ***ar)
+static BOOL uniarray_2_dosarray(BUFFER5 *buf5, char ***ar)
{
char **array;
char *string;
@@ -3750,7 +3750,7 @@ BOOL uniarray_2_ascarray(BUFFER5 *buf5, char ***ar)
while (dest < destend)
{
- *(dest++) = (char)*(src++);
+ dest += unicode_to_dos_char(dest, (smb_ucs2_t)*(src++));
}
/* that ugly for the first one but that's working */
@@ -3912,7 +3912,7 @@ BOOL uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *uni,
DEBUGADD(8,( "monitorname: %s\n", d->monitorname));
DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype));
- uniarray_2_ascarray(&(uni->dependentfiles), &(d->dependentfiles) );
+ uniarray_2_dosarray(&(uni->dependentfiles), &(d->dependentfiles) );
return True;
}