Skip to content
Myr

Catch .. as the first component of a module path

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Only the second and subsequent path components were being checked, which I guess is theoretically security-relevant. There's no apparent point to reconstructing the path after splitting it by adding /s back in, either.

authored by Muh Muhten · committed by Nico Williams · parent ff01482 · Browse files · 1 file+2 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−7 removed

  • other:+2 added−7 removed

1 file+2 added−7 removed

modified:src/linker.c+2 added-7 removed
96 unmodified lines
97 jv_free(name);98 return res;99 }100 jv components = jv_string_split(jv_copy(name), jv_string("/"));101 jv rp = jv_array_get(jv_copy(components), 0);102 components = jv_array_slice(components, 1, jv_array_length(jv_copy(components)));101 jv_array_foreach(components, i, x) {102 if (!strcmp(jv_string_value(x), "..")) {103 jv_free(x);106 jv_free(rp);104 jv_free(components);105 jv res = jv_invalid_with_msg(jv_string_fmt("Relative paths to modules may not traverse to parent directories (%s)", s));106 jv_free(name);107 return res;108 }109 if (i > 0 && jv_equal(jv_copy(x), jv_array_get(jv_copy(components), i - 1))) {110 jv_free(x);114 jv_free(rp);111 jv_free(components);112 jv res = jv_invalid_with_msg(jv_string_fmt("module names must not have equal consecutive components: %s",113 jv_string_value(name)));114 jv_free(name);115 return res;116 }121 rp = jv_string_concat(rp, jv_string_concat(jv_string("/"), x));117 jv_free(x);118 }119 jv_free(components);124 jv_free(name);125 return rp;120 return name;121}122123// Assumes name has been validated124static jv jv_basename(jv name) {
276 unmodified lines