Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309824
b: refs/heads/master
c: e7a0444
h: refs/heads/master
v: v3
  • Loading branch information
Weston Andros Adamson authored and J. Bruce Fields committed Jun 1, 2012
1 parent 457727d commit a3ec381
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 45eaa1c1a16122a98bf995c004c23806759d2e5f
refs/heads/master: e7a0444aef4a1649bc155fd5c6d6ab3f8bdc88ab
40 changes: 33 additions & 7 deletions trunk/fs/nfsd/nfs4xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1744,24 +1744,40 @@ static void encode_seqid_op_tail(struct nfsd4_compoundres *resp, __be32 *save, _
}

/* Encode as an array of strings the string given with components
* separated @sep.
* separated @sep, escaped with esc_enter and esc_exit.
*/
static __be32 nfsd4_encode_components(char sep, char *components,
__be32 **pp, int *buflen)
static __be32 nfsd4_encode_components_esc(char sep, char *components,
__be32 **pp, int *buflen,
char esc_enter, char esc_exit)
{
__be32 *p = *pp;
__be32 *countp = p;
int strlen, count=0;
char *str, *end;
char *str, *end, *next;

dprintk("nfsd4_encode_components(%s)\n", components);
if ((*buflen -= 4) < 0)
return nfserr_resource;
WRITE32(0); /* We will fill this in with @count later */
end = str = components;
while (*end) {
for (; *end && (*end != sep); end++)
; /* Point to end of component */
bool found_esc = false;

/* try to parse as esc_start, ..., esc_end, sep */
if (*str == esc_enter) {
for (; *end && (*end != esc_exit); end++)
/* find esc_exit or end of string */;
next = end + 1;
if (*end && (!*next || *next == sep)) {
str++;
found_esc = true;
}
}

if (!found_esc)
for (; *end && (*end != sep); end++)
/* find sep or end of string */;

strlen = end - str;
if (strlen) {
if ((*buflen -= ((XDR_QUADLEN(strlen) << 2) + 4)) < 0)
Expand All @@ -1780,6 +1796,15 @@ static __be32 nfsd4_encode_components(char sep, char *components,
return 0;
}

/* Encode as an array of strings the string given with components
* separated @sep.
*/
static __be32 nfsd4_encode_components(char sep, char *components,
__be32 **pp, int *buflen)
{
return nfsd4_encode_components_esc(sep, components, pp, buflen, 0, 0);
}

/*
* encode a location element of a fs_locations structure
*/
Expand All @@ -1789,7 +1814,8 @@ static __be32 nfsd4_encode_fs_location4(struct nfsd4_fs_location *location,
__be32 status;
__be32 *p = *pp;

status = nfsd4_encode_components(':', location->hosts, &p, buflen);
status = nfsd4_encode_components_esc(':', location->hosts, &p, buflen,
'[', ']');
if (status)
return status;
status = nfsd4_encode_components('/', location->path, &p, buflen);
Expand Down

0 comments on commit a3ec381

Please sign in to comment.