On Sat, Jan 21, 2012 at 10:46:57AM -0800, Chris Cappuccio wrote:
> Did this work?

I did an update to the cvs mg and can no longer reproduce the problem.
Seems it's already been fixed.

-Nima

> ----- Forwarded message from Loganaden Velvindron <[email protected]> -----
> 
> Date: Wed, 24 Aug 2011 17:57:40 -0400 (EDT)
> From: Loganaden Velvindron <[email protected]>
> To: [email protected]
> Subject: Re: [[email protected]: mg dired segfaults on some characters]
> 
> This is an initial attempt at fixing the problem.
> 
> Can you test this diff ? Please reverse the diff
> for warping the dot before applying this one.
> 
> Index: src/usr.bin/mg/dired.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/mg/dired.c,v
> retrieving revision 1.48
> diff -u -p -r1.48 dired.c
> --- src/usr.bin/mg/dired.c    23 Jan 2011 00:45:03 -0000      1.48
> +++ src/usr.bin/mg/dired.c    24 Aug 2011 21:46:05 -0000
> @@ -600,10 +600,13 @@ dired_(char *dname)
>  {
>       struct buffer   *bp;
>       FILE    *dirpipe;
> -     char     line[256];
> -     int      len, ret, counter, warp;
> +     char     line[256], tmp[256], ini[256];
> +     int      len, ret, counter, warp, pos;
> +     char    *meta, *orig;
> +     meta = "(){} ";
>       counter = 0;
>       warp = 0;
> +     pos = 0;
>  
>       if ((fopen(dname,"r")) == NULL) {
>               if (errno == EACCES)
> @@ -627,7 +630,20 @@ dired_(char *dname)
>       if (bclear(bp) != TRUE)
>               return (NULL);
>       bp->b_flag |= BFREADONLY;
> +
> +     (void) strlcpy(ini, dname, sizeof(ini));
> +     while (strpbrk(&ini[pos], meta) != NULL) {
> +             pos = strpbrk(&ini[pos], meta) - &ini[0];
> +             (void) strlcpy(tmp, &ini[pos], sizeof(tmp));
> +             ini[pos] = '\\';
> +             ini[pos+1] = '\0';
> +             (void) strlcat(&ini[pos], tmp, sizeof(ini));
> +             pos += 2;
> +     }
> +     orig = dname;
> +     dname = &ini[0];
>       ret = snprintf(line, sizeof(line), "ls -al %s", dname);
> +     dname = orig;
>       if (ret < 0 || ret  >= sizeof(line)) {
>               ewprintf("Path too long");
>               return (NULL);
> 
> ----- End forwarded message -----
> 
> -- 
> There are only three sports: bullfighting, motor racing, and mountaineering; 
> all the rest are merely games. - E. Hemingway

-- 
The pudding is in the proof.

Reply via email to