[linux-cifs-client] [PATCH 00/10] cifs: fix string conversions from wire format to local charset

Jeff Layton jlayton at redhat.com
Wed Apr 29 13:29:10 GMT 2009


This patchset is intended to fix the string conversions in cifs that
convert strings from "wire-format" (little-endian UTF-16) to whatever
character set is in use on the client.

This patch is built upon work by Suresh Jayaraman. This shouldn't be
taken as a comment on his work -- he did a fine job on the earlier
patchsets. It became clear to me as I was reviewing them though that
there were more fundamental problems with the existing code that
couldn't really be remedied without a more invasive set:

1) When converting into a destination buffer, the size of that buffer
isn't checked in a clear and consistent fashion. This patchset attempts
to remedy that by providing functions that do this.

2) In some functions there are clear limits on how many wide characters
the functions should walk. The numbers passed to them don't always
reflect the amount of data in the actual packet though, so it's possible
for these functions to walk off of the end of the source buffer. This
set attempts to fix that by making the callers of the new functions
consistently pass in a max size the reflects the size of the data left
in the response.

3) The function interfaces are inconsistent and use wide characters for
some lengths and bytes for others. This means that we often have to
convert between different length units and leads to more confusing code.
This patchset tries to settle on using lengths in bytes for most
interfaces since that is more useful when allocating buffers and such.

4) There are a lot of similar functions that could be consolidated. This
set does that where it makes sense.

There are a number of other bugs that are fixed in this. It also removes
some dead and broken code.

The set here is only lightly tested so far, but I wanted to post it to
collect comments. There are other legacy callers that this patchset
doesn't fix -- in particular the NTLMSSP code. That code is pretty much
unused, unmaintained and unmaintainable so my suggestion is that we just
rip it out.

Comments and suggestions appreciated...

Jeff Layton (10):
  cifs: add function to get length of NULL termination in bytes
  cifs: move #defines for mapchars into cifs_unicode.h
  cifs: add replacement for cifs_strtoUCS_le called
    cifs_utf16le_to_host
  cifs: add new function to get unicode string length in bytes
  cifs: rename cifs_strlcpy_to_host and make it use new functions
  cifs: convert CIFSTCon to use new unicode helper functions
  cifs: fix session setup unicode string saving to use new unicode
    helpers
  cifs: remove cifs_readlink and CIFSSMBQueryReparseLinkInfo
  cifs: change CIFSSMBUnixQuerySymLink to use new helpers
  cifs: change cifs_get_name_from_search_buf to use new unicode helper

 fs/cifs/cifs_unicode.c |  193 ++++++++++++++++++++++++++++++++++++++++++
 fs/cifs/cifs_unicode.h |   39 +++++++++
 fs/cifs/cifsfs.h       |    2 -
 fs/cifs/cifspdu.h      |   11 ---
 fs/cifs/cifsproto.h    |    5 +-
 fs/cifs/cifssmb.c      |  217 +++++------------------------------------------
 fs/cifs/connect.c      |   48 +++--------
 fs/cifs/link.c         |  114 +------------------------
 fs/cifs/misc.c         |   71 ----------------
 fs/cifs/readdir.c      |   26 +++---
 fs/cifs/sess.c         |   80 +++++-------------
 11 files changed, 309 insertions(+), 497 deletions(-)



More information about the linux-cifs-client mailing list