misson20000 / twili

Homebrew debug monitor for the Nintendo Switch.
GNU General Public License v3.0
184 stars 23 forks source link

bridge: Don't error out when sending a 0-byte response. #100

Closed comex closed 4 years ago

comex commented 4 years ago

Both the USB and TCP bridge had issues in this case. For USB, it would try to send a 0-byte USB packet but the USB stack would return an error. For TCP, it seems like bsd_send would return 0 and twili would then interpret that as an error (haven't actually tested this).

misson20000 commented 4 years ago

Any idea what was sending zero-byte response fragments?

comex commented 4 years ago

investigates

It was GetNroInfos returning an empty vector. In fact, it seems like it always returns an empty vector at the moment, as nro_info never gets assigned to.

Then PackingHelper for std::vector<T> does

        w.Write<uint64_t>(vec.size());
        w.Write(vec);

and the latter Write call (to ResponseWriter) does

        return Write((uint8_t*) data.data(), data.size() * sizeof(T));
misson20000 commented 4 years ago

Mmm, makes sense. Probably explains the issues I had with NRO stuff in GDB stub.