fix a bug about length field in header