*printf(3) functions have some locale(5) specific behaviors. In source/libsmb/nmblib.c, put_nmb_name() and name_mangle() function use slprintf() (snprintf(3)) to format NetBIOS name (in dos charset) and name type. But on the following situation, slprintf() fails and buffer is not set: slprintf( buffuer, sizeof(buffuer), "%-15.15s", "valid chars in dos charset, but invalid in current locale(5) setting" ); Please use a locale-indepent functions in this situation.
Created attachment 405 [details] proposed patch to fix this bug Attach a proposed patch.
Oops... s/locale-indepent/locale-independent/ in description.
# Can you hear me? :) Oops. My proposed patch causes SIGSEVG if strlen(name) is longer than 15. --- nmblib.c.old 2004-02-17 18:08:55.000000000 +0900 +++ nmblib.c 2004-02-23 19:44:16.000000000 +0900 @@ -264,7 +264,9 @@ static void put_name(char *dest, const c size_t len = strlen(name); memcpy(dest, name, (len <= 15) ? len : 15); - memset(dest + len, pad, 15 - len); + if (len < 15) { + memset(dest + len, pad, 15 - len); + } dest[15] = name_type; }
In init_iconv() we go to charset_name() and there we may initialize setlocale() to locale environment under which application runs if one of 'dos charset, unix charset, or display charset' settings is 'LOCALE'. It is default for 'display charset'. However, nmbd and smbd usually start as daemons and from init scripts thus having locale POSIX effectively set up. So, you observation is valid for default Samba settings. I'll look into the patch soon.
The patch in Additional Comment #1 is included in a patch attached in Bug 784.
This bug was gone by Samba 3.0.3 or later.
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.