added assert to check that the return value from extract packet is valid

if extractPacket returns a value bigger than the buffer size, this will
cause a core dump later on.