From mat@hak.cnd.mcgill.ca  Wed Jun  4 20:55:18 2003
Return-Path: <mat@hak.cnd.mcgill.ca>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1386B37B404
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  4 Jun 2003 20:55:18 -0700 (PDT)
Received: from hak.cnd.mcgill.ca (hak.cnd.mcgill.ca [132.216.11.133])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 49B6943F85
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  4 Jun 2003 20:55:17 -0700 (PDT)
	(envelope-from mat@hak.cnd.mcgill.ca)
Received: from hak.cnd.mcgill.ca (localhost.cnd.mcgill.ca [127.0.0.1])
	by hak.cnd.mcgill.ca (8.12.3p2/8.12.3) with ESMTP id h553wGjC051472
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 4 Jun 2003 23:58:16 -0400 (EDT)
	(envelope-from mat@hak.cnd.mcgill.ca)
Received: (from mat@localhost)
	by hak.cnd.mcgill.ca (8.12.3p2/8.12.3/Submit) id h553wGnB051471;
	Wed, 4 Jun 2003 23:58:16 -0400 (EDT)
Message-Id: <200306050358.h553wGnB051471@hak.cnd.mcgill.ca>
Date: Wed, 4 Jun 2003 23:58:16 -0400 (EDT)
From: Mathew Kanner <mat@hak.cnd.mcgill.ca>
Reply-To: Mathew Kanner <mat@hak.cnd.mcgill.ca>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: kbdcontrol macros don't work when len = 16
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         52960
>Category:       kern
>Synopsis:       [kbd] kbdcontrol macros don't work when len = 16
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jmg
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 04 21:00:31 PDT 2003
>Closed-Date:    Sun Jun 10 06:21:42 GMT 2007
>Last-Modified:  Sun Jun 10 06:21:42 GMT 2007
>Originator:     Mathew Kanner
>Release:        FreeBSD 4.6.2-RELEASE i386 (and -current)
>Organization:
Center for Non-Linear Dynamics
>Environment:
System: FreeBSD hak.cnd.mcgill.ca 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #0: Wed Aug 14 21:23:26 GMT 2002 murray@builder.freebsdmall.com:/usr/src/sys/compile/GENERIC i386

	Also applicable to -current (as of a few weeks ago).

>Description:
	Kbdcontrol won't send out macros exactly 16 chars wide.
>How-To-Repeat:
	
kbdcontrol -f 10 "12345678901234567"
kbdcontrol: function key string too long (17 > 16)
kbdcontrol -f 10 "1234567890123456"
[Hit f10 then nothing]
kbdcontrol -f 10 "123456789012345"
[Hit f10 then ] 123456789012345

>Fix:

	Sorry, haven't looked.

>Release-Note:
>Audit-Trail:

From: Dmitry Sivachenko <mitya@demos.su>
To: freebsd-gnats-submit@FreeBSD.org
Cc: mat@hak.cnd.mcgill.ca
Subject: Re: kern/52960: kbdcontrol macros don't work when len%
Date: Thu, 5 Jun 2003 14:24:50 +0400

 The following patch fixes the problem.  When you supply exactly
 MAXFK(=16) chararacters as a macro, you should use strncpy which does not
 append trailing '\0'.
 
 
 --- kbdcontrol.c.orig	Thu Jun  5 14:19:13 2003
 +++ kbdcontrol.c	Thu Jun  5 14:17:52 2003
 @@ -848,7 +848,7 @@
  			fkey.flen, MAXFK);
  		return;
  	}
 -	strcpy(fkey.keydef, string);
 +	strncpy(fkey.keydef, string, MAXFK);
  	fkey.keynum -= 1;
  	if (ioctl(0, SETFKEY, &fkey) < 0)
  		warn("setting function key");

From: Mathew Kanner <mat@cnd.mcgill.ca>
To: Dmitry Sivachenko <mitya@demos.su>
Cc: freebsd-gnats-submit@FreeBSD.org, mat@hak.cnd.mcgill.ca
Subject: Re: kern/52960: kbdcontrol macros don't work when len%
Date: Thu, 5 Jun 2003 13:55:06 -0400

 On Jun 05, Dmitry Sivachenko wrote:
 > The following patch fixes the problem.  When you supply exactly
 > MAXFK(=16) chararacters as a macro, you should use strncpy which does not
 > append trailing '\0'.
 
 	Wow, that was fast.  Patch works on -stable and -current.
 
 	--Mat
 
 
 -- 
 Brain: Pinky, are you pondering what I'm pondering?
 Pinky: I think so Brain, but pants with horizontal stripes make me
 look chubby.
Responsible-Changed-From-To: freebsd-bugs->jmg 
Responsible-Changed-By: jmg 
Responsible-Changed-When: Fri Dec 5 11:24:39 PST 2003 
Responsible-Changed-Why:  
I'll take a look at this, seems sad that such a small patch will slip through 
the cracks, also, 
http://bsdroolz.port5.com/patch 
has another patch relating to this. 
Message-ID: <1070548976.3fcf47f0d36b6@webmail.k7-net.net> 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52960 
State-Changed-From-To: open->patched 
State-Changed-By: jmg 
State-Changed-When: Mon Aug 9 04:28:26 GMT 2004 
State-Changed-Why:  
patched in -current will MFC in a week or so... 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52960 
State-Changed-From-To: patched->closed 
State-Changed-By: linimon 
State-Changed-When: Sun Jun 10 06:21:28 UTC 2007 
State-Changed-Why:  
RELENG_4 is now out of support, so this PR is obsolete. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52960 
>Unformatted:
