[Spice-devel] [PATCH] [vd_agent] fix bug: g_key_get_string() of vd_agent failed when keystring contains '['
Christophe Fergeau
cfergeau at redhat.com
Mon Aug 11 03:33:37 PDT 2014
Hey,
On Fri, Aug 08, 2014 at 08:33:59PM +0800, Cody Chan wrote:
> Hi, as you can see, in vd_agent/file_xfer.cpp, it implemented
> the g_key_get_string,
> but I find a problem, when dragging a file with a name containing '[' (like
> te[st.txt), it will be failed.
> From source code,
> >next_group_pos = strstr(group_pos + strlen(group_pfx), "[");
> > if (next_group_pos && key_pos > next_group_pos) return false;
> we know that it tries to find the end of current group by '[' label,
> if we drag a file like te[st.txt, the key_string many like:
> [vdagent-file-xfer]
> name=te[st.txt
> size=10
> so, it's failed when meta parsing and
> returns VD_AGENT_FILE_XFER_STATUS_ERRO message.
>
> I find a way to fix it, just replace '[' ']' with '<' '>' between group
> name,
> for it's illegal for windows to create a file with a name containing
> '<'/'>'.
Unfortunately, I don't think we can change the file format at this
point, especially as this format is based on the somehow standard 'ini'
file format, and apart from the windows agent, we use glib
GKeyFile parser to handle this format.
From a quick look at the code, wouldn't the patch below avoid the issue
you described?
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index c258926..17cdb3c 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -203,7 +203,7 @@ bool FileXfer::g_key_get_string(char* data, const
char* grou
sprintf_s(key_pfx, sizeof(key_pfx), "\n%s=", key);
if (!(key_pos = strstr(group_pos, key_pfx))) return false;
- next_group_pos = strstr(group_pos + strlen(group_pfx), "[");
+ next_group_pos = strstr(group_pos + strlen(group_pfx), "\n[");
if (next_group_pos && key_pos > next_group_pos) return false;
start = key_pos + strlen(key_pfx);
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20140811/4cc3879a/attachment.sig>
More information about the Spice-devel
mailing list