From owner-freebsd-bugs Sun Feb 23 11: 0:14 2003 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7498B37B405 for ; Sun, 23 Feb 2003 11:00:11 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id C585743FBF for ; Sun, 23 Feb 2003 11:00:09 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h1NJ09NS065886 for ; Sun, 23 Feb 2003 11:00:09 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h1NJ09gW065885; Sun, 23 Feb 2003 11:00:09 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 08C9C37B405 for ; Sun, 23 Feb 2003 10:50:50 -0800 (PST) Received: from grosbein.pp.ru (www2.svzserv.kemerovo.su [213.184.65.86]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8368D43FA3 for ; Sun, 23 Feb 2003 10:50:43 -0800 (PST) (envelope-from eugen@grosbein.pp.ru) Received: from grosbein.pp.ru (smmsp@localhost [127.0.0.1]) by grosbein.pp.ru (8.12.7/8.12.7) with ESMTP id h1NIoX99001181 for ; Mon, 24 Feb 2003 01:50:33 +0700 (KRAT) (envelope-from eugen@grosbein.pp.ru) Received: (from eugen@localhost) by grosbein.pp.ru (8.12.7/8.12.7/Submit) id h1NIZCSi000423; Mon, 24 Feb 2003 01:35:12 +0700 (KRAT) Message-Id: <200302231835.h1NIZCSi000423@grosbein.pp.ru> Date: Mon, 24 Feb 2003 01:35:12 +0700 (KRAT) From: Eugene Grosbein Reply-To: Eugene Grosbein To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/48599: [PATCH] syscons cut-n-paste logic is broken Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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