bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: crash inserting character before a special and a normal one


From: Philippe Biondi
Subject: Re: crash inserting character before a special and a normal one
Date: Thu, 17 Apr 2003 19:38:28 +0200 (CEST)

On Thu, 17 Apr 2003, Tobias Rittweiler wrote:

> On Thursday, April 17, 2003 at 6:54:40 PM,
>     Philippe Biondi <biondi@cartel-securite.fr> wrote:
>
> > > Try the patch from
> > >         http://mail.gnu.org/archive/html/bug-bash/2003-04/msg00026.html
> >
> > -      memset (ps, 0, sizeof(mbstate_t));
> > +      if (ps != NULL) memset (ps, 0, sizeof(mbstate_t));
> >
> > That will fix the problem. But is it normal for "ps" to be null here ?
> > I could not determine that as I can't match my sources with the binary
> > verion I have.
>
> Well, firstly mbrlen(3) says:
>         If ps is a NULL pointer, a static anonymous state only known
>         to the mbrlen function is used instead.
> That means, mbrlen _can_ work with passing a NULL pointer as ps --
> readline can't deny that and just assume ps is never NULL. Well,
> actually it could do that, but that wouldn't be good programming
> practise, imho. :-)
>
> And second, the source of update_line() (in display.c) is as follows:
>
> 1206 #if defined (HANDLE_MULTIBYTE)
> 1207   /* This may not work for stateful encoding, but who cares? To handle
> 1208      stateful encoding properly, we have to scan each string from the
> 1209      beginning and compare. */
> 1210   else if (_rl_compare_chars (ols, 0, NULL, nls, 0, NULL) == 0)
> 1211 #else
> 1212   else if (*ols != *nls)
> 1213 #endif
>
> Purpose is to test whether ols isn't equal to nls, and it's the
> correct way to pass NULL as ps in this circumstance, asfaics.

Thanks for that explaination. I'm convinced :)

Best regards, Phil.

-- 
Philippe Biondi <biondi@ cartel-securite.fr> Cartel Sécurité
Security Consultant/R&D                      http://www.cartel-securite.fr
Phone: +33 1 44 06 97 94                     Fax: +33 1 44 06 97 99
PGP KeyID:3D9A43E2  FingerPrint:C40A772533730E39330DC0985EE8FF5F3D9A43E2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]