Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cpptraj interactive mode can crash out with a long command line #958

Closed
drroe opened this issue Mar 18, 2022 · 2 comments
Closed

Cpptraj interactive mode can crash out with a long command line #958

drroe opened this issue Mar 18, 2022 · 2 comments
Assignees
Labels

Comments

@drroe
Copy link
Contributor

drroe commented Mar 18, 2022

Problem is the CpptrajFile::Printf buffer gets overrun. Need to either fix Printf or use Write instead.

@drroe drroe added the bug label Mar 18, 2022
@drroe drroe self-assigned this Mar 18, 2022
@drroe
Copy link
Contributor Author

drroe commented Mar 18, 2022

This should work:

diff --git a/AmberTools/src/cpptraj/src/Cpptraj.cpp b/AmberTools/src/cpptraj/src/Cpptraj.cpp
index f6857fab2f..5d94b8dacb 100644
--- a/AmberTools/src/cpptraj/src/Cpptraj.cpp
+++ b/AmberTools/src/cpptraj/src/Cpptraj.cpp
@@ -650,8 +650,11 @@ int Cpptraj::Interactive() {
   if (logfile_.IsOpen()) {
     // Write logfile header entry: date, cmd line opts, topologies
     logfile_.Printf("# %s\n", TimeString().c_str());
-    if (!commandLine_.empty())
-      logfile_.Printf("# Args: %s\n", commandLine_.c_str());
+    if (!commandLine_.empty()) {
+      logfile_.Printf("# Args: ");
+      logfile_.Write(commandLine_.c_str(), commandLine_.size());
+      logfile_.Printf("\n");
+    }
     DataSetList tops = State_.DSL().GetSetsOfType("*", DataSet::TOPOLOGY);
     if (!tops.empty()) {
       logfile_.Printf("# Loaded topologies:\n");

@drroe
Copy link
Contributor Author

drroe commented Aug 30, 2022

Fixed by #959

@drroe drroe closed this as completed Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant