From b985eb16130c8422a27a83151a00d4096cfcf559 Mon Sep 17 00:00:00 2001 From: brapru Date: Tue, 18 May 2021 22:24:37 -0400 Subject: [PATCH] Utilities: Allow for white spaces in lsof name parsing Previously lsof would crash by incorrectly parsing valid file names that contain spaces. For example, established TCP socket file descriptors would cause an lsof crash: socket:127.0.0.1:33985 / 127.0.0.1:8080 (connected) This commit fixes the issue by not parsing for white spaces to set the file name. --- Userland/Utilities/lsof.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Utilities/lsof.cpp b/Userland/Utilities/lsof.cpp index c3e0f143f7..09481fc9fd 100644 --- a/Userland/Utilities/lsof.cpp +++ b/Userland/Utilities/lsof.cpp @@ -38,7 +38,7 @@ static bool parse_name(StringView name, OpenFile& file) return true; } else { file.type = component1; - auto component2 = lexer.consume_while([](char c) { return isprint(c) && !isspace(c) && c != '('; }); + auto component2 = lexer.consume_while([](char c) { return isprint(c) && c != '('; }); lexer.ignore_while(isspace); file.name = component2;