Each of tvb_get_stringz
, tvb_get_ephemeral_stringz
, and tvb_get_seasonal_stringz
extract a NULL
terminated string from the TVB and return it as a guint8 *
.
I would recommend that you check for the presence of the terminating NULL
before calling any of these functions, however, as it is not guaranteed to be in the captured packet (erroneous transmission, fuzz-test, fragmentation, etc). You could use tvb_find_guint8
to do this; a returned length of -1
means that the NULL
was not found before the end of the packet or maxlength
(an argument to the call).
answered 18 Apr '11, 13:00
multipleinte...
1.3k●15●23●40
accept rate: 12%
I am using following function and then checking if it is -1 or not. / check for null character / null_offset = tvb_find_guint8(tvb, offset + 1, -1,0);
Thank You. It really helped me.
Note that if the terminating NUL is not found, tvb_get_stringz(), tvb_get_ephemeral_stringz(), and tvb_get_seasonal_stringz() will throw an exception, so that the packet will be reported as either cut short by the snapshot length (if it hits the captured length before finding a NUL or hitting the end of the packet) or malformed (if it hits the end of the packet before finding a NUL and the captured length and packet length are the same). In most cases, this is what you'd want - no need for the tvb_find_guint8().
Thanks to all. I was able to do what i wanted to do.
(please use the "accept" button (the checkmark next to an answer) to accept an answer, this will make sure the question is removed from the "Unanswered Questions" list)