Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion kernel/src/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,21 @@ static void resolve_path(const char* input, char* output) {
while (curr < temp_len) {
while (curr < temp_len && temp[curr] == '/') curr++;
if (curr >= temp_len) break;

if (num_parts >= 32) {
// Path is deeper than we can represent in the shell resolver.
// Skip the rest to avoid stack corruption.
while (curr < temp_len && temp[curr] != '/') curr++;
continue;
Comment on lines +117 to +121
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep processing .. once path depth reaches cap

When num_parts hits 32, this branch skips every remaining segment without inspecting its value, so later .. components are ignored instead of popping depth. In deep but valid paths like /a/.../z/../target (where the cap is reached before ..), resolve_path() now normalizes to the wrong directory and write flows can operate on an unintended path; this is a functional regression introduced by the new early continue.

Useful? React with 👍 / 👎.

}

int p = 0;
while (curr < temp_len && temp[curr] != '/' && p < 31) {
parts[num_parts][p++] = temp[curr++];
}
// Consume overly long segment tail so parser stays in sync.
while (curr < temp_len && temp[curr] != '/') curr++;

parts[num_parts][p] = '\0';
if (str_eq(parts[num_parts], ".")) {
// Nothing
Expand All @@ -135,9 +146,10 @@ static void resolve_path(const char* input, char* output) {

int out_len = 0;
for (int i = 0; i < num_parts; i++) {
if (out_len >= 255) break;
output[out_len++] = '/';
int p = 0;
while (parts[i][p]) output[out_len++] = parts[i][p++];
while (parts[i][p] && out_len < 255) output[out_len++] = parts[i][p++];
}
output[out_len] = '\0';
}
Expand Down