interesting fact about StrCaseCmp
Martin Pool
mbp at samba.org
Tue Feb 18 04:23:40 GMT 2003
On 18 Feb 2003, jra at dp.samba.org wrote:
> What exactly do you want to do here ? I'm not clear what
> you mean?
The thing I noticed is that StrCaseCmp (and indeed many charcnv
function) truncate strings to 1024 characters.
I got here following a Valgrind assertion which may or may not be
related, but it certainly seems like a bug.
What I was proposing in the first instance was to use talloced or
malloced buffers rather than a fixed 1024 byte space. There are
already some charcnv routines that do this and in any case it is
straightforward to do it for other cases using the standard
measure-allocate-copy method.
Andrew expressed concern that allocating buffers would be inefficient,
but these functions are already extremely inefficient so I don't think
an extra malloc would matter.
In fact, it's worse, because unix_strupper (for example) uses a
1024-*byte* buffer to hold a UCS2 string. I don't think it will
overflow, but it will truncate any strings that pass through down to
512 characters. It's not so hard to imagine a 512-character string.
Basically I just wanted to push on with moving away from
pstrings/fstrings, which I understood from Andrew & Tim to be the
current direction.
--
Martin
More information about the samba-technical
mailing list