Hello:
I'm not on the list so please CC me.
I sent the following PR to gnats@ but it doesn't seem to have made it
to bugs@. The PR query system at http://openbsd.org/query-pr.html
doesn't seem to be working either so I'm forwarding the PR here.
Cheers,
-Nima
--
The pudding is in the proof.
- Forwarded message from nh...@nimahoda.net -
Date: Mon, 22 Aug 2011 21:00:34 -0400 (EDT)
From: nh...@nimahoda.net
Subject: mg dired segfaults on some characters
To: gn...@openbsd.org
Cc: nh...@rostam.nimahoda.net
Reply-To: nimah...@gmail.com
>Synopsis: mg dired segfaults on some characters
>Category: userland
>Environment:
System : OpenBSD 4.8
Details : OpenBSD 4.8 (GENERIC.MP) #335: Mon Aug 16 09:09:20 MDT
2010
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
Architecture: OpenBSD.amd64
Machine : amd64
>Description:
current mg from cvs segfaults in dired mode when "finding" a
directory path that contains characters that the shell interprets
specially, such as parentheses.
>How-To-Repeat:
$ mkdir \(
$ mg .
Move point (the cursor) up to the line corresponding to the directory
'(' and hit 'Enter'. The follow is output to the terminal
sh: syntax error: `(' unexpected
and mg segfaults.
>Fix:
Here is a patch that mitigates (but doesn't fully solve) the problem.
Even with this patch, there are problems with path names containing
single quotes but they no longer lead to segfault.
Index: dired.c
===
RCS file: /cvs/src/usr.bin/mg/dired.c,v
retrieving revision 1.48
diff -u -r1.48 dired.c
--- dired.c 23 Jan 2011 00:45:03 - 1.48
+++ dired.c 23 Aug 2011 00:56:30 -
@@ -627,7 +627,7 @@
if (bclear(bp) != TRUE)
return (NULL);
bp->b_flag |= BFREADONLY;
- ret = snprintf(line, sizeof(line), "ls -al %s", dname);
+ ret = snprintf(line, sizeof(line), "ls -al '%s'", dname);
if (ret < 0 || ret >= sizeof(line)) {
ewprintf("Path too long");
return (NULL);
@@ -652,7 +652,11 @@
}
if ((strrchr(line,' ')) != NULL)
bp->b_doto = strrchr(line,' ') - line + 1;
- if (pclose(dirpipe) == -1) {
+ ret = pclose(dirpipe);
+ if (ret > 0) {
+ ewprintf("Problem reading directory contents");
+ return (NULL);
+ } else if (ret == -1) {
ewprintf("Problem closing pipe to ls : %s",
strerror(errno));
return (NULL);
dmesg:
OpenBSD 4.8 (GENERIC.MP) #335: Mon Aug 16 09:09:20 MDT 2010
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 2145189888 (2045MB)
avail mem = 2074263552 (1978MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe0010 (68 entries)
bios0: vendor LENOVO version "7IET33WW (1.14 )" date 04/16/2008
bios0: LENOVO 87445BU
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SSDT ECDT TCPA APIC MCFG HPET SLIC BOOT SSDT SSDT SSDT
SSDT
acpi0: wakeup devices LID_(S3) SLPB(S3) LURT(S3) DURT(S3) EXP0(S4) EXP1(S4)
EXP2(S4) EXP3(S4) PCI1(S4) USB0(S3) USB1(S3) USB2(S3) USB7(S3) HDEF(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpiec0 at acpi0
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz, 1994.66 MHz
cpu0:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,NXE,LONG
cpu0: 4MB 64b/line 16-way L2 cache
cpu0: apic clock running at 166MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz, 1994.34 MHz
cpu1:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,NXE,LONG
cpu1: 4MB 64b/line 16-way L2 cache
ioapic0 at mainbus0: apid 1 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 2, remapped to apid 1
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (AGP_)
acpiprt2 at acpi0: bus 2 (EXP0)
acpiprt3 at acpi0: bus 3 (EXP1)
acpiprt4 at acpi0: bus 4 (EXP2)
acpiprt5 at acpi0: bus 12 (EXP3)
acpiprt6 at acpi0: bus 21 (PCI1)
acpicpu0 at acpi0: C3, C2, C1, PSS
acpicpu1 at acpi0: C3, C2, C1, PSS
acpipwrres0 at acpi0: PUBS
acpitz0 at acpi0: critical temperature 127 degC
acpitz1 at acpi0: critical temperature 100 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model "92P1139" serial 4774 type LION oem "Panasonic"
acpibat1 at acpi0: BAT1 not present
acpiac0 at acpi0: AC unit online
acpithinkpad0 at acpi0
acpidock0 at