summaryrefslogtreecommitdiff
path: root/vdagent
diff options
context:
space:
mode:
authorCody Chan <int64ago@gmail.com>2014-08-13 23:43:56 +0800
committerChristophe Fergeau <cfergeau@redhat.com>2014-11-13 16:52:19 +0100
commit6c070843cb00635bc8bab5fd98b8fefb597e7557 (patch)
tree210b7f8a4a89125e1dfc54610e29782def8f251e /vdagent
parent21b79679c1345225ceba8d015f5efe9113d146fb (diff)
Fix g_key_get_string() failure when string contains '['
In vd_agent/file_xfer.cpp is implemented a simple g_key_get_string, but when dragging a file with a name containing '[' (like te[st.txt), it will fail. 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 named te[st.txt, the key_string will be like: [vdagent-file-xfer] name=te[st.txt size=10 so, it will fail when meta parsing and returns the VD_AGENT_FILE_XFER_STATUS_ERROR message. Here's the elegant method Christophe proposed and test ok, thanks to him again!
Diffstat (limited to 'vdagent')
-rw-r--r--vdagent/file_xfer.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index 9eec5cc..208303f 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -206,7 +206,7 @@ bool FileXfer::g_key_get_string(char* data, const char* group, const char* key,
snprintf(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);