Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Ethereal-dev: Re: [Ethereal-dev] Weird bug on MSVC build only (probably HTTP or tvb_get_ptr)

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Guy Harris" <gharris@xxxxxxxxx>
Date: Thu, 29 Apr 2004 17:02:43 -0700 (PDT)
Biot Olivier said:
> If I inspect the last function from the stack, the debugger points at
> basic_response_dissector() in packet-http.c at the if statement:
>
> 	if (sscanf((const gchar *)data, "%d.%d %d", &minor, &major,
> &status_code) == 3) {

Oh, *that's* not good.  As far as I know, "sscanf()" takes, as its first
argument, a C string - i.e., it has to be null-terminated, and...

> If I inspect the value returned from the statement on the line before
> the if statement:
>
> 	data = tvb_get_ptr(tvb, 5, 12);

...that's not guaranteed to be null-terminated.  (I'm not sure it's
guaranteed to have 12 characters, either....)

Perhaps it should, instead, parse the response line itself, using
"req_strlen" as an indication of the number of characters in the string
*after* the first 5 characters rather than expecting "data" to be
null-terminated.