Print this page
NEX-19025 CIFS gets confused with filenames containing enhanced Unicode
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
and: (fix build, check-rtime)
NEX-2460 libfksmbd should not link with libsmb
SMB-65 SMB server in non-global zones (data structure changes)
Many things move to the smb_server_t object, and
many functions gain an sv arg (which server).

Split Close
Expand all
Collapse all
          --- old/usr/src/common/smbsrv/smb_string.c
          +++ new/usr/src/common/smbsrv/smb_string.c
↓ open down ↓ 166 lines elided ↑ open up ↑
 167  167          uint16_t mask = is_unicode ? 0xffff : 0xff;
 168  168  
 169  169          return (current_codepage[c & mask].ctype & CODEPAGE_ISLOWER);
 170  170  }
 171  171  
 172  172  /*
 173  173   * Convert individual characters to their uppercase equivalent value.
 174  174   * If the specified character is lowercase, the uppercase value will
 175  175   * be returned. Otherwise the original value will be returned.
 176  176   */
 177      -int
 178      -smb_toupper(int c)
      177 +uint32_t
      178 +smb_toupper(uint32_t c)
 179  179  {
 180  180          uint16_t mask = is_unicode ? 0xffff : 0xff;
 181  181  
 182  182          return (current_codepage[c & mask].upper);
 183  183  }
 184  184  
 185  185  /*
 186  186   * Convert individual characters to their lowercase equivalent value.
 187  187   * If the specified character is uppercase, the lowercase value will
 188  188   * be returned. Otherwise the original value will be returned.
 189  189   */
 190      -int
 191      -smb_tolower(int c)
      190 +uint32_t
      191 +smb_tolower(uint32_t c)
 192  192  {
 193  193          uint16_t mask = is_unicode ? 0xffff : 0xff;
 194  194  
 195  195          return (current_codepage[c & mask].lower);
 196  196  }
 197  197  
 198  198  /*
 199  199   * Convert a string to uppercase using the appropriate codepage. The
 200  200   * string is converted in place. A pointer to the string is returned.
 201  201   * There is an assumption here that uppercase and lowercase values
 202  202   * always result encode to the same length.
 203  203   */
 204  204  char *
 205  205  smb_strupr(char *s)
 206  206  {
 207      -        smb_wchar_t c;
      207 +        uint32_t c;
 208  208          char *p = s;
 209  209  
 210  210          while (*p) {
 211  211                  if (smb_isascii(*p)) {
 212  212                          *p = smb_toupper(*p);
 213  213                          p++;
 214  214                  } else {
 215  215                          if (smb_mbtowc(&c, p, MTS_MB_CHAR_MAX) < 0)
 216  216                                  return (0);
 217  217  
↓ open down ↓ 10 lines elided ↑ open up ↑
 228  228  
 229  229  /*
 230  230   * Convert a string to lowercase using the appropriate codepage. The
 231  231   * string is converted in place. A pointer to the string is returned.
 232  232   * There is an assumption here that uppercase and lowercase values
 233  233   * always result encode to the same length.
 234  234   */
 235  235  char *
 236  236  smb_strlwr(char *s)
 237  237  {
 238      -        smb_wchar_t c;
      238 +        uint32_t c;
 239  239          char *p = s;
 240  240  
 241  241          while (*p) {
 242  242                  if (smb_isascii(*p)) {
 243  243                          *p = smb_tolower(*p);
 244  244                          p++;
 245  245                  } else {
 246  246                          if (smb_mbtowc(&c, p, MTS_MB_CHAR_MAX) < 0)
 247  247                                  return (0);
 248  248  
↓ open down ↓ 8 lines elided ↑ open up ↑
 257  257          return (s);
 258  258  }
 259  259  
 260  260  /*
 261  261   * Returns 1 if string contains NO uppercase chars 0 otherwise. However,
 262  262   * -1 is returned if "s" is not a valid multi-byte string.
 263  263   */
 264  264  int
 265  265  smb_isstrlwr(const char *s)
 266  266  {
 267      -        smb_wchar_t c;
      267 +        uint32_t c;
 268  268          int n;
 269  269          const char *p = s;
 270  270  
 271  271          while (*p) {
 272  272                  if (smb_isascii(*p) && smb_isupper(*p))
 273  273                          return (0);
 274  274                  else {
 275  275                          if ((n = smb_mbtowc(&c, p, MTS_MB_CHAR_MAX)) < 0)
 276  276                                  return (-1);
 277  277  
↓ open down ↓ 10 lines elided ↑ open up ↑
 288  288          return (1);
 289  289  }
 290  290  
 291  291  /*
 292  292   * Returns 1 if string contains NO lowercase chars 0 otherwise. However,
 293  293   * -1 is returned if "s" is not a valid multi-byte string.
 294  294   */
 295  295  int
 296  296  smb_isstrupr(const char *s)
 297  297  {
 298      -        smb_wchar_t c;
      298 +        uint32_t c;
 299  299          int n;
 300  300          const char *p = s;
 301  301  
 302  302          while (*p) {
 303  303                  if (smb_isascii(*p) && smb_islower(*p))
 304  304                          return (0);
 305  305                  else {
 306  306                          if ((n = smb_mbtowc(&c, p, MTS_MB_CHAR_MAX)) < 0)
 307  307                                  return (-1);
 308  308  
↓ open down ↓ 124 lines elided ↑ open up ↑
 433  433   * Although a standard UNC path starts with two '\', in DFS
 434  434   * all UNC paths start with one '\'. So, this function only
 435  435   * checks for one.
 436  436   *
 437  437   * A valid UNC must at least contain two components i.e. server
 438  438   * and share. The path is parsed to:
 439  439   *
 440  440   * unc_server   server or domain name with no leading/trailing '\'
 441  441   * unc_share    share name with no leading/trailing '\'
 442  442   * unc_path     relative path to the share with no leading/trailing '\'
 443      - *              it is valid for unc_path to be NULL.
      443 + *              it is valid for unc_path to be NULL.
 444  444   *
 445  445   * Upon successful return of this function, smb_unc_free()
 446  446   * MUST be called when returned 'unc' is no longer needed.
 447  447   *
 448  448   * Returns 0 on success, otherwise returns an errno code.
 449  449   */
 450  450  int
 451  451  smb_unc_init(const char *path, smb_unc_t *unc)
 452  452  {
 453  453          char *p;
↓ open down ↓ 64 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX