Re: [Wireshark-dev] Is there a need for a 0, NULL element at the end of value strings

2018-10-16 Thread Richard Sharpe
On Tue, Oct 16, 2018 at 10:21 AM Guy Harris  wrote:
>
> On Oct 16, 2018, at 8:30 AM, Richard Sharpe  
> wrote:
>
> > OK, ignore me. When you call g_array_new with TRUE in the first
> > argument you get a ZERO entry on the end.
>
> The fact that you had to ask this question - and probably had to look that up 
> in the GLib documentation - suggests that there should be a comment before 
> the g_array_new() call to indicate that the first argument being TRUE adds 
> the necessary null terminator.  (*I* certainly didn't remember that the 
> argument to g_array_new() indicates whether to put a zero terminator into the 
> array; I suspect few people who aren't heavy GLib developers would know that 
> without looking it up.)

Yes, that is what I did. It probably does require a comment. I will
add one before my next change set.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)(传说杜康是酒的发明者)
___
Sent via:Wireshark-dev mailing list 
Archives:https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
 mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe

Re: [Wireshark-dev] Is there a need for a 0, NULL element at the end of value strings

2018-10-16 Thread Guy Harris
On Oct 16, 2018, at 8:30 AM, Richard Sharpe  wrote:

> OK, ignore me. When you call g_array_new with TRUE in the first
> argument you get a ZERO entry on the end.

The fact that you had to ask this question - and probably had to look that up 
in the GLib documentation - suggests that there should be a comment before the 
g_array_new() call to indicate that the first argument being TRUE adds the 
necessary null terminator.  (*I* certainly didn't remember that the argument to 
g_array_new() indicates whether to put a zero terminator into the array; I 
suspect few people who aren't heavy GLib developers would know that without 
looking it up.)
___
Sent via:Wireshark-dev mailing list 
Archives:https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
 mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe

Re: [Wireshark-dev] Is there a need for a 0, NULL element at the end of value strings

2018-10-16 Thread Richard Sharpe
On Tue, Oct 16, 2018 at 8:24 AM Richard Sharpe
 wrote:
>
> Hi folks,
>
> I have always put a {0, NULL} element on the end of value strings, but
> it seems the lua code for constructing value strings when you use
> ProtoField(..., some_value_string) does not terminate the list with an
> empty element, and my test did not cause a crash.
>
> Rather, I got an "unknown" field as expected.
>
> Can anyone confirm they are not needed?

OK, ignore me. When you call g_array_new with TRUE in the first
argument you get a ZERO entry on the end.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)(传说杜康是酒的发明者)
___
Sent via:Wireshark-dev mailing list 
Archives:https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
 mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe

Re: [Wireshark-dev] Is there a need for a 0, NULL element at the end of value strings

2018-10-16 Thread Pascal Quantin
Hi Richard,

Le mar. 16 oct. 2018 à 17:26, Richard Sharpe 
a écrit :

> Hi folks,
>
> I have always put a {0, NULL} element on the end of value strings, but
> it seems the lua code for constructing value strings when you use
> ProtoField(..., some_value_string) does not terminate the list with an
> empty element, and my test did not cause a crash.
>
> Rather, I got an "unknown" field as expected.
>
> Can anyone confirm they are not needed?
>

With C code, their presence is mandatory to properly end the loop in
try_val_to_str_idx/try_val64_to_str_idx functions without doing an out of
bounds access. I have no checked the Lua wrapper code.

BR,
Pascal.
___
Sent via:Wireshark-dev mailing list 
Archives:https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
 mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe

[Wireshark-dev] Is there a need for a 0, NULL element at the end of value strings

2018-10-16 Thread Richard Sharpe
Hi folks,

I have always put a {0, NULL} element on the end of value strings, but
it seems the lua code for constructing value strings when you use
ProtoField(..., some_value_string) does not terminate the list with an
empty element, and my test did not cause a crash.

Rather, I got an "unknown" field as expected.

Can anyone confirm they are not needed?

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)(传说杜康是酒的发明者)
___
Sent via:Wireshark-dev mailing list 
Archives:https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
 mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe