Date: Mon, 24 Feb 2003 01:35:12 +0700 (KRAT) From: Eugene Grosbein <eugen@grosbein.pp.ru> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/48599: [PATCH] syscons cut-n-paste logic is broken Message-ID: <200302231835.h1NIZCSi000423@grosbein.pp.ru>
next in thread | raw e-mail | index | archive | help
>Number: 48599
>Category: kern
>Synopsis: [PATCH] syscons cut-n-paste logic is broken
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Feb 23 11:00:09 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Eugene Grosbein
>Release: FreeBSD 4.8-PRERELEASE i386
>Organization:
Svyaz Service JSC
>Environment:
System: FreeBSD grosbein.pp.ru 4.8-PRERELEASE FreeBSD 4.8-PRERELEASE #13: Mon Feb 24 00:54:18 KRAT 2003 eu@grosbein.pp.ru:/usr/local/obj/usr/local/src/sys/DADV i386
>Description:
Today I tried to mark and paste into a letter one message
written to a console by the kernel:
/kernel: linux: 'ioctl' fd=25, cmd=0x60b ('?',11) not implemented
There was a symbol with code 0x06 in place of ? actually.
And syscons failed to paste complete line. The last symbol
pasted was "'" that stands just before 0x06.
>How-To-Repeat:
A simple demonstration provided by the next line:
for i in `jot 7 1; do printf "$i\\$i.$i\n"; done
Try to mark one of the lines (four symbols) and paste the selection -
syscons will paste only first symbol.
>Fix:
Printed symbols 0x01, 0x02, 0x03 appear as 0x00 for mouse_cut().
I do not know if it is intended behavour. If so, it breaks
cut-n-paste and that should be fixed, see patch below.
Additional review of possibly unsafe sc_vtb_getc() usage may be needed.
The patch is for src/sys/dev/syscons/scmouse.c, it replaces 0x00
with space (0x20) when pasting.
--- scmouse.c.orig Sun Feb 23 23:29:38 2003
+++ scmouse.c Mon Feb 24 01:24:31 2003
@@ -336,7 +336,8 @@
to = start - 1;
}
for (p = from, i = blank = 0; p <= to; ++p) {
- cut_buffer[i] = sc_vtb_getc(&scp->vtb, p);
+ if ((cut_buffer[i] = sc_vtb_getc(&scp->vtb, p)) == '\0')
+ cut_buffer[i]=' ';
/* remember the position of the last non-space char */
if (!IS_SPACE_CHAR(cut_buffer[i++]))
blank = i; /* the first space after the last non-space */
@@ -416,6 +417,8 @@
scp->mouse_cut_end = scp->mouse_cut_start;
splx(s);
cut_buffer[0] = sc_vtb_getc(&scp->vtb, scp->mouse_cut_start);
+ if (cut_buffer[0] == '\0')
+ cut_buffer[0]=' ';
cut_buffer[1] = '\0';
scp->status |= MOUSE_CUTTING;
}
@@ -497,8 +500,9 @@
}
/* copy the found word */
- for (i = 0, j = start; j <= end; ++j)
- cut_buffer[i++] = sc_vtb_getc(&scp->vtb, j);
+ for (i = 0, j = start; j <= end; ++i, ++j)
+ if ((cut_buffer[i] = sc_vtb_getc(&scp->vtb, j)) == '\0')
+ cut_buffer[i] = ' ';
cut_buffer[i] = '\0';
scp->status |= MOUSE_CUTTING;
@@ -540,8 +544,9 @@
splx(s);
/* copy the line into the cut buffer */
- for (i = 0, j = scp->mouse_cut_start; j <= scp->mouse_cut_end; ++j)
- cut_buffer[i++] = sc_vtb_getc(&scp->vtb, j);
+ for (i = 0, j = scp->mouse_cut_start; j <= scp->mouse_cut_end; ++i, ++j)
+ if ((cut_buffer[i] = sc_vtb_getc(&scp->vtb, j)) == '\0')
+ cut_buffer[i] = ' ';
cut_buffer[i++] = '\r';
cut_buffer[i] = '\0';
scp->status |= MOUSE_CUTTING;
Eugene Grosbein
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302231835.h1NIZCSi000423>
