tcp: avoid consuming trailing bytes