Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 229070
b: refs/heads/master
c: 219fd58
h: refs/heads/master
v: v3
  • Loading branch information
M. Mohan Kumar authored and Eric Van Hensbergen committed Jan 11, 2011
1 parent 371f24f commit a92304f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 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: af7542fc8ac678ce69dbd5c9643c52897b47c66f
refs/heads/master: 219fd58be62d01e30224c7af919dea77b7e392a8
22 changes: 10 additions & 12 deletions trunk/net/9p/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,27 +178,24 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
break;
case 's':{
char **sptr = va_arg(ap, char **);
int16_t len;
int size;
uint16_t len;

errcode = p9pdu_readf(pdu, proto_version,
"w", &len);
if (errcode)
break;

size = max_t(int16_t, len, 0);

*sptr = kmalloc(size + 1, GFP_KERNEL);
*sptr = kmalloc(len + 1, GFP_KERNEL);
if (*sptr == NULL) {
errcode = -EFAULT;
break;
}
if (pdu_read(pdu, *sptr, size)) {
if (pdu_read(pdu, *sptr, len)) {
errcode = -EFAULT;
kfree(*sptr);
*sptr = NULL;
} else
(*sptr)[size] = 0;
(*sptr)[len] = 0;
}
break;
case 'Q':{
Expand Down Expand Up @@ -234,14 +231,14 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
}
break;
case 'D':{
int32_t *count = va_arg(ap, int32_t *);
uint32_t *count = va_arg(ap, uint32_t *);
void **data = va_arg(ap, void **);

errcode =
p9pdu_readf(pdu, proto_version, "d", count);
if (!errcode) {
*count =
min_t(int32_t, *count,
min_t(uint32_t, *count,
pdu->size - pdu->offset);
*data = &pdu->sdata[pdu->offset];
}
Expand Down Expand Up @@ -404,9 +401,10 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
break;
case 's':{
const char *sptr = va_arg(ap, const char *);
int16_t len = 0;
uint16_t len = 0;
if (sptr)
len = min_t(int16_t, strlen(sptr), USHRT_MAX);
len = min_t(uint16_t, strlen(sptr),
USHRT_MAX);

errcode = p9pdu_writef(pdu, proto_version,
"w", len);
Expand Down Expand Up @@ -438,7 +436,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
stbuf->n_gid, stbuf->n_muid);
} break;
case 'D':{
int32_t count = va_arg(ap, int32_t);
uint32_t count = va_arg(ap, uint32_t);
const void *data = va_arg(ap, const void *);

errcode = p9pdu_writef(pdu, proto_version, "d",
Expand Down

0 comments on commit a92304f

Please sign in to comment.