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

cli socket path bug fix #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

moshehe
Copy link

@moshehe moshehe commented Aug 16, 2023

Bug in the CLI socket

The OpenBTS-UMTSCLI app is unable to locate the socket used for sending commands to OpenBTS-UMTS app

Steps to Reproduce the Bug

  1. Run the OpenBTS-UMTS Application:

    • Launch the OpenBTS-UMTS application by running: ./OpenBTS-UMTS.
  2. Run the OpenBTS-UMTSCLI Application:

    • Launch the OpenBTS-UMTS application by running: ./OpenBTS-UMTSCLI.
  3. Send command from the CLI app:

    • In the OpenBTS-UMTSCLI app run a command e.g rawconfig.
  4. Expected Behavior:

    • The command is expected to be sent to the OpenBTS-UMTS application, and the corresponding response should be displayed.
  5. Actual Behavior:

    • Instead, the output is:
     sending datagram: No such file or directory
     Is the remote application running?
    

Root Cause

The reason for this problem is the way of saving the path string of the CLI socket.
In apps/OpenBTS-UMTS.cpp line 263:

const char* sockpath = gConfig.getStr("CLI.SocketPath").c_str();

The c_str function returns a pointer that points to the internal array currently used by the string object. However, as we are only using a pointer to the object without retaining the string object itself, the pointer refers to an array containing garbage values instead of the correct path (which is /var/run/OpenBTS-UMTS-command by default). Consequently, rather than opening the socket in the intended path, the code attempts to open the socket file with a nonsensical name in the current directory.

Fix

To address this bug, I introduced a new variable to hold the string object, and then added another variable of type char* to reference the array within the string object. With these changes, the socket now opens correctly in the expected path, allowing the successful transmission of commands from OpenBTS-UMTSCLI app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant