Skip to content

Commit

Permalink
cifs: fix length handling in cifs_get_name_from_search_buf
Browse files Browse the repository at this point in the history
The earlier patch to move this code to use the new unicode helpers
assumed that the filename strings would be null terminated. That's not
always the case.

Instead of passing "max_len" to the string converter, pass "min(len,
max_len)", which makes it do the right thing while still keeping the
parser confined to the response. Also fix up the prototypes of this
function and the callers so that max_len is unsigned (like len is).

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
  • Loading branch information
Jeff Layton authored and Steve French committed May 1, 2009
1 parent 9e39b0a commit 1829579
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions fs/cifs/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
/* inode num, inode type and filename returned */
static int cifs_get_name_from_search_buf(struct qstr *pqst,
char *current_entry, __u16 level, unsigned int unicode,
struct cifs_sb_info *cifs_sb, int max_len, __u64 *pinum)
struct cifs_sb_info *cifs_sb, unsigned int max_len, __u64 *pinum)
{
int rc = 0;
unsigned int len = 0;
Expand Down Expand Up @@ -890,7 +890,8 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
if (unicode) {
pqst->len = cifs_from_ucs2((char *) pqst->name,
(__le16 *) filename,
UNICODE_NAME_MAX, max_len, nlt,
UNICODE_NAME_MAX,
min(len, max_len), nlt,
cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
} else {
Expand All @@ -902,8 +903,8 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
return rc;
}

static int cifs_filldir(char *pfindEntry, struct file *file,
filldir_t filldir, void *direntry, char *scratch_buf, int max_len)
static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir,
void *direntry, char *scratch_buf, unsigned int max_len)
{
int rc = 0;
struct qstr qstring;
Expand Down Expand Up @@ -1000,7 +1001,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
int num_to_fill = 0;
char *tmp_buf = NULL;
char *end_of_smb;
int max_len;
unsigned int max_len;

xid = GetXid();

Expand Down

0 comments on commit 1829579

Please sign in to comment.