Menu

#2823 Network props.cxx Segfault with bad input syntax

2020.4
Fixed
None
Low
2023-08-25
2023-08-24
No

Using the 'setd' , set decimal value to property, command with this bad syntax ( the space delimiter is missing between property name and new value) :

    client.print("setd controls/engines/engine/throttle");
    client.print(cumlThrt);
    client.print("\r\n");

causes a segfault at flightgear/src/Network/props.cxx @ 601:

              tmp += tokens[2].c_str();

bea\cause there aren't three tokens. Rewriting that block of code to log an error prevents the segfault and logs an error message ( props.cxx @ 592 :

      else if ( command == "setd" || command == "setf") {
          std::string value, tmp;
          if (tokens.size() == 3) {
            node->getNode( tokens[1].c_str(), true )
                ->setDoubleValue(atof(tokens[2].c_str()));
            if ( mode == PROMPT ) {
                tmp = tokens[1].c_str();
                tmp += " ";
                tmp += tokens[2].c_str();
                tmp += " (";
                tmp += getValueTypeString( node->getNode( tokens[1].c_str() ) );
                tmp += ")";
                push( tmp.c_str() );
                push( getTerminator() );
            }
        } else {
                SG_LOG( SG_IO, SG_ALERT, "Network I/O  setd / setf wrong token count" );
        }
      }

I'm guessing the following 'setb' block could be similarly modified.
Patch for the fix attached

1 Attachments

Discussion

  • James Turner

    James Turner - 2023-08-25

    Agreed, I'll apply.

     
  • Huntley Palmer

    Huntley Palmer - 2023-08-25

    Thank You !

     
  • James Turner

    James Turner - 2023-08-25
    • status: New --> Started
    • assigned_to: James Turner
     
  • James Turner

    James Turner - 2023-08-25

    Pushed some changes to FG git, please test.

     
  • James Turner

    James Turner - 2023-08-25
    • status: Started --> Fixed
     
  • Huntley Palmer

    Huntley Palmer - 2023-08-25

    Um, It looks like the change in NasalCondition is stopping a build here:
    /fgfs/flightgear/src/Scripting/NasalCondition.hxx:24:32: error: 'function' in namespace 'std' does not name a tem a €€€€€ plate type a €€€€€€€€€
    24 | using NasalCallback = std::function<void(naref)>; a €€€€€€€€€
    | ^~~~~~~~ a €€€€€€€€€
    /fgfs/flightgear/src/Scripting/NasalCondition.hxx:9:1: note: 'std::function' is defined in header '<functional>'; a €€€€€€€€€ did you forget to '#include <functional>'? </functional></functional></void(naref)>

     
  • Huntley Palmer

    Huntley Palmer - 2023-08-25

    Added *include <functional>" in Scripting/NasalCondition.hxx fixed the build.
    Tested set, setb, setd, setf, seti with good and bad arguments, telnet, all looks good, Thanks ! </functional>

     

Log in to post a comment.

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.