提交 05818a00 编写于 作者: L Latchesar Ionkov 提交者: Linus Torvalds

[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: NLatchesar Ionkov <lucho@ionkov.net>
Cc: Eric Van Hensbergen <ericvh@ericvh.myip.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 93c615fe
...@@ -116,13 +116,19 @@ static void buf_put_int64(struct cbuf *buf, u64 val) ...@@ -116,13 +116,19 @@ static void buf_put_int64(struct cbuf *buf, u64 val)
} }
} }
static void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) static char *buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)
{ {
char *ret;
ret = NULL;
if (buf_check_size(buf, slen + 2)) { if (buf_check_size(buf, slen + 2)) {
buf_put_int16(buf, slen); buf_put_int16(buf, slen);
ret = buf->p;
memcpy(buf->p, s, slen); memcpy(buf->p, s, slen);
buf->p += slen; buf->p += slen;
} }
return ret;
} }
static inline void buf_put_string(struct cbuf *buf, const char *s) static inline void buf_put_string(struct cbuf *buf, const char *s)
...@@ -430,15 +436,19 @@ static inline void v9fs_put_int64(struct cbuf *bufp, u64 val, u64 * p) ...@@ -430,15 +436,19 @@ static inline void v9fs_put_int64(struct cbuf *bufp, u64 val, u64 * p)
static void static void
v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str) v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str)
{ {
if (data) { int len;
str->len = strlen(data); char *s;
str->str = bufp->p;
} else { if (data)
str->len = 0; len = strlen(data);
str->str = NULL; else
} len = 0;
buf_put_stringn(bufp, data, str->len); s = buf_put_stringn(bufp, data, len);
if (str) {
str->len = len;
str->str = s;
}
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册