Re:QtNat – Open you port with Qt UPnP
by jeffbee on Friday January 09, 2026 @03:43PM
(#46559070)
"My network packets are parsed with C++". I spotted undefined behavior triggered by packet contents in less than 1 minute of reading this example. If the packet contains "\rhttp://" it passes a negative-size `n` parameter to QString::sliced, which is UB.
[ Parent
| on HN ]
Average "well written" C++ program that is free of bugs.
I'm looking at the code but I don't quite see that?
auto start= result.indexOf("http://");
...
auto end= result.indexOf("\r", start);
...
m_describeUrl= result.sliced(start, end - start);
I don't think end can ever be < start (other than < 0 if not found, which is handled).