diff options
author | Eugene Tarassov | 2011-12-21 21:47:39 +0000 |
---|---|---|
committer | Eugene Tarassov | 2011-12-21 21:47:39 +0000 |
commit | 2b8bb173f6964e4acf6ce85e51f9b5d102291318 (patch) | |
tree | ac934381933f3cf34a8bf8b58473221892615c65 | |
parent | c9207d2e16e2469facb2f43f9d1991b4d1f48885 (diff) | |
download | org.eclipse.tcf.agent-2b8bb173f6964e4acf6ce85e51f9b5d102291318.tar.gz org.eclipse.tcf.agent-2b8bb173f6964e4acf6ce85e51f9b5d102291318.tar.xz org.eclipse.tcf.agent-2b8bb173f6964e4acf6ce85e51f9b5d102291318.zip |
TCF Agent: fixed page fault when a client sends PathMap.set command with an empty string as "Destination".
-rw-r--r-- | services/pathmap.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/services/pathmap.c b/services/pathmap.c index 6bc88cfe..d6fc8778 100644 --- a/services/pathmap.c +++ b/services/pathmap.c @@ -298,7 +298,7 @@ static int update_rule(PathMapRule * r, PathMapRuleAttribute * new_attrs) { } static char * map_file_name(Context * ctx, PathMap * m, char * fnm, int mode) { - unsigned i, j, k; + unsigned i, k; static char buf[FILE_PATH_SIZE]; for (i = 0; i < m->rules_cnt; i++) { @@ -336,8 +336,10 @@ static char * map_file_name(Context * ctx, PathMap * m, char * fnm, int mode) { continue; k = 0; } - j = strlen(r->dst) - 1; - if (fnm[k] != 0 && (r->dst[j] == '/' || r->dst[j] == '\\')) k++; + if (r->dst[0] != 0) { + size_t j = strlen(r->dst) - 1; + if (fnm[k] != 0 && (r->dst[j] == '/' || r->dst[j] == '\\')) k++; + } snprintf(buf, sizeof(buf), "%s%s", r->dst, fnm + k); if (mode != PATH_MAP_TO_LOCAL || stat(buf, &st) == 0) return buf; } |