gem5-dev@gem5.org

The gem5 Developer List

View all threads

[XS] Change in gem5/gem5[develop]: base: error out when socker path too long

EO
Earl Ou (Gerrit)
Mon, Apr 10, 2023 6:13 AM

Earl Ou has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/69482?usp=email )

Change subject: base: error out when socker path too long
......................................................................

base: error out when socker path too long

When unix socket path is too long, we should simply error out the
execution instead of keeping running with an unexpected path and
warning.

Change-Id: I736727807ac41a23c5dac563dd8c904f3eec92b1

M src/base/socket.cc
1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/base/socket.cc b/src/base/socket.cc
index 2e9f815..554513b 100644
--- a/src/base/socket.cc
+++ b/src/base/socket.cc
@@ -95,13 +95,8 @@

  std::string resolved_path = resolve(path);
  std::string fmt_path = replace(resolved_path, '\0', '@');
  • if (resolved_path.size() > max_len) {
  •    resolved_path = resolved_path.substr(0, max_len);
    
  •    const std::string untruncated_path = std::move(fmt_path);
    
  •    fmt_path = replace(resolved_path, '\0', '@');
    
  •    warn("SocketPath: unix socket path truncated from '%s' to '%s'",
    
  •         untruncated_path, fmt_path);
    
  • }
  • panic_if(resolved_path.size() > max_len,
  •         "SocketPath: unix socket path too long.");
    
    // We can't use strncpy here, since abstract sockets start with \0  
    

which
// will make strncpy think that the string is empty.

--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/69482?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I736727807ac41a23c5dac563dd8c904f3eec92b1
Gerrit-Change-Number: 69482
Gerrit-PatchSet: 1
Gerrit-Owner: Earl Ou shunhsingou@google.com
Gerrit-MessageType: newchange

Earl Ou has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/69482?usp=email ) Change subject: base: error out when socker path too long ...................................................................... base: error out when socker path too long When unix socket path is too long, we should simply error out the execution instead of keeping running with an unexpected path and warning. Change-Id: I736727807ac41a23c5dac563dd8c904f3eec92b1 --- M src/base/socket.cc 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/base/socket.cc b/src/base/socket.cc index 2e9f815..554513b 100644 --- a/src/base/socket.cc +++ b/src/base/socket.cc @@ -95,13 +95,8 @@ std::string resolved_path = resolve(path); std::string fmt_path = replace(resolved_path, '\0', '@'); - if (resolved_path.size() > max_len) { - resolved_path = resolved_path.substr(0, max_len); - const std::string untruncated_path = std::move(fmt_path); - fmt_path = replace(resolved_path, '\0', '@'); - warn("SocketPath: unix socket path truncated from '%s' to '%s'", - untruncated_path, fmt_path); - } + panic_if(resolved_path.size() > max_len, + "SocketPath: unix socket path too long."); // We can't use strncpy here, since abstract sockets start with \0 which // will make strncpy think that the string is empty. -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/69482?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: develop Gerrit-Change-Id: I736727807ac41a23c5dac563dd8c904f3eec92b1 Gerrit-Change-Number: 69482 Gerrit-PatchSet: 1 Gerrit-Owner: Earl Ou <shunhsingou@google.com> Gerrit-MessageType: newchange