[Asterisk-Dev] Re: asterisk enum.c,1.20,1.20.2.1

Kevin P. Fleming kpfleming at starnetworks.us
Thu Mar 17 08:21:35 MST 2005


Tony Mountifield wrote:

> :-O surely the "some reason" should be identified before deciding on a patch!

Yeah, I wasn't thrilled with that either, but given the fact that this 
application had been in CVS and _never_ worked properly, I figured this 
was a step in the right direction so I didn't push any harder for a 
better patch.

> That is another clue. In fact the string in question was "\x0BJared Smith".
> Just looking at that, it is obvious that the 0x0B byte is a length field
> with value 11, because there are 11 characters in "Jared Smith".

Right, and I'm sure there are docs to back that up.

> I haven't looked at the original code yet, the patch doesn't show
> where len comes from, but any termination byte should be written in a
> place determined by that first length byte.

A patch to do that would be most welcome, although you can't just use 
the length byte as the size to pass to strncpy, since it needs the size 
of the output buffer, not the input length. However, that length could 
certainly be used to good effect to make the code clearer and easier to 
understand.



More information about the asterisk-dev mailing list