Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2015-06-11 18:22:57 +0000
committerEugene Tarassov2015-06-11 18:30:23 +0000
commitb9a735e9c7cf82f80d412b7ab15d08b89d5a4ccc (patch)
tree107fc4c108f4a39f19e4f13b0cd84da5bd3d66bd /agent/tcf/services
parent0155733135573d91e50e2bb52ab3444707a46077 (diff)
downloadorg.eclipse.tcf.agent-b9a735e9c7cf82f80d412b7ab15d08b89d5a4ccc.tar.gz
org.eclipse.tcf.agent-b9a735e9c7cf82f80d412b7ab15d08b89d5a4ccc.tar.xz
org.eclipse.tcf.agent-b9a735e9c7cf82f80d412b7ab15d08b89d5a4ccc.zip
Bug 469954 - FileSystem readlink returns trailing garbage1.3.01.3_mars_bugfix
Diffstat (limited to 'agent/tcf/services')
-rw-r--r--agent/tcf/services/filesystem.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/agent/tcf/services/filesystem.c b/agent/tcf/services/filesystem.c
index 119e9d44..47962250 100644
--- a/agent/tcf/services/filesystem.c
+++ b/agent/tcf/services/filesystem.c
@@ -1440,23 +1440,27 @@ static void command_rename(char * token, Channel * c) {
static void command_readlink(char * token, Channel * c) {
char path[FILE_PATH_SIZE];
char link[FILE_PATH_SIZE];
- int err;
+ ssize_t len = 0;
+ int err = 0;
read_path(&c->inp, path, sizeof(path));
json_test_char(&c->inp, MARKER_EOA);
json_test_char(&c->inp, MARKER_EOM);
- link[0] = 0;
#if defined(_WIN32) || defined(_WRS_KERNEL)
err = ENOSYS;
#else
- err = (readlink(path, link, sizeof(link)) < 0) ? errno : 0;
+ len = readlink(path, link, sizeof(link));
+ if (len < 0) {
+ err = errno;
+ len = 0;
+ }
#endif
write_stringz(&c->out, "R");
write_stringz(&c->out, token);
write_fs_errno(&c->out, err);
- json_write_string(&c->out, link);
+ json_write_string_len(&c->out, link, (size_t)len);
write_stream(&c->out, 0);
write_stream(&c->out, MARKER_EOM);
}

Back to the top