Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed bug #51860 (Include fails with toplevel symlink to /)

  • Loading branch information...
commit 0d32d361e63193b09051c4cb285df1ed015d91b7 1 parent 2c1285a
Dmitry Stogov authored

Showing 1 changed file with 15 additions and 3 deletions. Show diff stats Hide diff stats

  1. +15 3 TSRM/tsrm_virtual_cwd.c
18 TSRM/tsrm_virtual_cwd.c
@@ -760,6 +760,9 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
760 760
761 761 while (1) {
762 762 if (len <= start) {
  763 + if (link_is_dir) {
  764 + *link_is_dir = 1;
  765 + }
763 766 return start;
764 767 }
765 768
@@ -776,6 +779,10 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
776 779 continue;
777 780 } else if (i == len - 2 && path[i] == '.' && path[i+1] == '.') {
778 781 /* remove '..' and previous directory */
  782 + is_dir = 1;
  783 + if (link_is_dir) {
  784 + *link_is_dir = 1;
  785 + }
779 786 if (i - 1 <= start) {
780 787 return start ? start : len;
781 788 }
@@ -1200,9 +1207,14 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
1200 1207 return 1;
1201 1208 }
1202 1209 memcpy(resolved_path, state->cwd, state_cwd_length);
1203   - resolved_path[state_cwd_length] = DEFAULT_SLASH;
1204   - memcpy(resolved_path + state_cwd_length + 1, path, path_length + 1);
1205   - path_length += state_cwd_length + 1;
  1210 + if (resolved_path[state_cwd_length-1] == DEFAULT_SLASH) {
  1211 + memcpy(resolved_path + state_cwd_length, path, path_length + 1);
  1212 + path_length += state_cwd_length;
  1213 + } else {
  1214 + resolved_path[state_cwd_length] = DEFAULT_SLASH;
  1215 + memcpy(resolved_path + state_cwd_length + 1, path, path_length + 1);
  1216 + path_length += state_cwd_length + 1;
  1217 + }
1206 1218 }
1207 1219 } else {
1208 1220 #ifdef TSRM_WIN32

0 comments on commit 0d32d36

Please sign in to comment.
Something went wrong with that request. Please try again.