Hi,
I'm not too fond of using pointer arithmetic in such cases. How about this:
str = ep_alloc(MAX_STR_LEN);
str_index = 0;
str[str_index]='\0';
/* sub authorities, leave RID to last */
for(i=0; i < (num_auth > 4?(num_auth - 1):num_auth); i++){
/*
* XXX should not be letohl but native byteorder according to
* Samba header files.
*
* However, considering that there were never any NT ports
* to big-endian platforms (PowerPC and MIPS ran little-endian,
* and IA-64 runs little-endian, as does x86-64), we can (?)
* assume that non le byte encodings will be "uncommon"?
*/
DISSECTOR_ASSERT(str_index <= MAX_STR_LEN);
returned_length = g_snprintf(&str[str_index], MAX_STR_LEN-str_index,
(i>0 ? "-%u" : "%u"), tvb_get_letohl(tvb, offset));
str_index += min(returned_length, (MAX_STR_LEN-str_index));
offset += 4;
}
Thanx,
Jaap
On Sat, 14 Jan 2006, Joerg Mayer wrote:
> On Sat, Jan 14, 2006 at 05:32:39AM -0600, bugzilla-do-not-reply@xxxxxxxxxxxx wrote:
> > http://bugs.ethereal.com/bugzilla/show_bug.cgi?id=686
> > What |Removed |Added
> > ----------------------------------------------------------------------------
> > Status|NEW |RESOLVED
> > Resolution| |FIXED
> >
> > ------- Additional Comments From jmayer@xxxxxxxxx 2006-01-14 05:32 CST6CDT -------
> > We may not work with the length returned by g_snprintf, as this is
> > the number of bytes that would have been used if the buffer was long
> > enough.
> >
> > Fixed 17030.
>
> Can someone please have a look at this fix? While I think that it is
> correct, maybe there is a more elegant solution to this.
> Once someone has looked into it, I'll check whether this problem occurrs
> in other places too.
>
> Thanks
> Joerg