Commit 05818a004a84951fd383694f3b35d89eb49fa308
Committed by
Linus Torvalds
1 parent
93c615feff
Exists in
master
and in
7 other branches
[PATCH] v9fs: v9fs_put_str fix
v9fs_put_str used to store pointer to the source string, instead of the cbuf copy. This patch corrects it. Signed-off-by: Latchesar Ionkov <lucho@ionkov.net> Cc: Eric Van Hensbergen <ericvh@ericvh.myip.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 19 additions and 9 deletions Side-by-side Diff
fs/9p/conv.c
... | ... | @@ -116,13 +116,19 @@ |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | -static void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) | |
119 | +static char *buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) | |
120 | 120 | { |
121 | + char *ret; | |
122 | + | |
123 | + ret = NULL; | |
121 | 124 | if (buf_check_size(buf, slen + 2)) { |
122 | 125 | buf_put_int16(buf, slen); |
126 | + ret = buf->p; | |
123 | 127 | memcpy(buf->p, s, slen); |
124 | 128 | buf->p += slen; |
125 | 129 | } |
130 | + | |
131 | + return ret; | |
126 | 132 | } |
127 | 133 | |
128 | 134 | static inline void buf_put_string(struct cbuf *buf, const char *s) |
129 | 135 | |
... | ... | @@ -430,15 +436,19 @@ |
430 | 436 | static void |
431 | 437 | v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str) |
432 | 438 | { |
433 | - if (data) { | |
434 | - str->len = strlen(data); | |
435 | - str->str = bufp->p; | |
436 | - } else { | |
437 | - str->len = 0; | |
438 | - str->str = NULL; | |
439 | - } | |
439 | + int len; | |
440 | + char *s; | |
440 | 441 | |
441 | - buf_put_stringn(bufp, data, str->len); | |
442 | + if (data) | |
443 | + len = strlen(data); | |
444 | + else | |
445 | + len = 0; | |
446 | + | |
447 | + s = buf_put_stringn(bufp, data, len); | |
448 | + if (str) { | |
449 | + str->len = len; | |
450 | + str->str = s; | |
451 | + } | |
442 | 452 | } |
443 | 453 | |
444 | 454 | static int |