Re: c# segmentation fault [with file]



> I changed some highlight words. There was only one version before this one,
> so you can make a patch from the CVS.
> 
> Juan C. Olivares
> 
> ----- Original Message ----- 
> From: "Pavel Roskin" <proski gnu org>
> To: "Juan Cristóbal Olivares C." <juancri TAGnet org>
> Cc: <mc-devel gnome org>
> Sent: Tuesday, September 09, 2003 6:55 PM
> Subject: Re: c# segmentation fault [with file]
> 
> 
> > On Tue, 9 Sep 2003, [iso-8859-1] Juan Crist?bal Olivares C. wrote:
> >
> > > File attached.
> >
> > OK, I cannot reproduce the segmentation fault, but the text in single
> > quotes becomes black.  The reason is a space inside the curly braces
> > instead of \0x7F.  Actually, \0x7F shouldn't be there because it's a
> > control character, so I'm removing it.

This space divided your keyword and second part was treated as foreground
color.  This part was too long to fit in stack allocated buffer, so we had
classic buffer overflow.  This bug fixed in CVS since 2003-02-25.

Patch attached.

-- 
Regards,
Andrew V. Samoilov.
--- mc-4.6.0/edit/syntax.c	Fri Sep 19 22:21:47 2003
+++ mc/edit/syntax.c	Fri Sep 19 21:46:48 2003
@@ -536,14 +586,16 @@ this_try_alloc_color_pair (char *fg, cha
 	if (!*fg)
 	    fg = 0;
     if (fg) {
-	strcpy (f, fg);
+	strncpy (f, fg, sizeof (f) - 1);
+	f[sizeof (f) - 1] = 0;
 	p = strchr (f, '/');
 	if (p)
 	    *p = '\0';
 	fg = f;
     }
     if (bg) {
-	strcpy (b, bg);
+	strncpy (b, bg, sizeof (b) - 1);
+	b[sizeof (b) - 1] = 0;
 	p = strchr (b, '/');
 	if (p)
 	    *p = '\0';


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