mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:27:46 +00:00
Utilities: Print arbitrary bytes in ls
Currently, `ls` crashes when printing certain byte sequences. This is likely due to an out-of-bounds error when iterating through the `StringView` representing the file name to be printed. We switch to using an index-based for loop to a range-based for loop. This fixes #16678.
This commit is contained in:
parent
41e0e4cdd7
commit
9724797da7
1 changed files with 4 additions and 4 deletions
|
@ -207,12 +207,12 @@ static int print_escaped(StringView name)
|
|||
return utf8_name.length();
|
||||
}
|
||||
|
||||
for (int i = 0; name[i] != '\0'; i++) {
|
||||
if (isprint(name[i])) {
|
||||
putchar(name[i]);
|
||||
for (auto c : name) {
|
||||
if (isprint(c)) {
|
||||
putchar(c);
|
||||
printed++;
|
||||
} else {
|
||||
printed += printf("\\%03d", name[i]);
|
||||
printed += printf("\\%03d", c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue