Encoding conversion patch

Lee H lee at leeh.co.uk
Thu May 19 18:26:01 EDT 2005


On Fri, May 20, 2005 at 01:44:21AM +0400, Alexander Kolov wrote:
> I wrote a small patch to use different encodings on different ports, but it
> has one major bug: in send.c, when string is put into send buffer it
> sometimes has some garbage at end, but converted string don't, so I can't
> calculate valid len value and it corrupts messages.
> Any ideas how to fix that, and if possible, other bugs?
> 
> You can get the patch here: http://www.love-wind.jp/recode.diff

You're allocating the memory to store listener_encoding in ircd_parser.y,
then passing a pointer to this memory down to add_listener().  At this
point, add_listener() should create its own copy of it and use that in the
listener, but youre instead setting it to whats been allocated in
ircd_parser.y.  As soon as you get another listener_encoding, this memory is
free()'d - except youve still got a pointer to it in your listener struct.

Your listener should allocate its own copy of the encoding.

I'd also advise you dont use strcpy() unless youre *absolutely* sure that
youre never going to get an overflow.  Use strlcpy() instead.

-- 
-                 Lee H // anfl
-        I code, therefore I break things.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.ircd-hybrid.org/pipermail/hybrid/attachments/20050519/4e722105/attachment.pgp>


More information about the hybrid mailing list