p4lang / tdi

Table-Driven Interface (TDI) for a P4-programmable backend device.
Apache License 2.0
40 stars 23 forks source link

Few fixes for string type input #136

Closed ruchitg closed 2 months ago

ruchitg commented 2 months ago
  1. If the input string is mentioned as hex, take the hex representation otherwise take the input bytes and convert them to ASCII for further processing.

  2. Pass the length of input bytes/string. Use this length to copy and process the string bytes. This will mitigate the risk of buffer overflows, memory corruption or information leakage and other string issues which might occur while processing string without knowning it's length. The fix will also enable to pass and have NULL char and other special chars as part of string.

swaroopsarma commented 2 months ago

i recommend to introduce a new c_frontend api for this purpose, and also a new member in the class rather than changing existing prototype. This will benefit in 2 ways. 1) backward compatibility 2)not impacting any other existing functionality if this is in use for any other platform

saynb commented 2 months ago

I agree with adding a new API instead. This breaks backward compatibility