9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] possible buffer overflow in devcons.c?
@ 2014-06-18 17:29 Yoann Padioleau
  2014-06-18 17:34 ` erik quanstrom
  2014-06-18 17:34 ` andrey mirtchovski
  0 siblings, 2 replies; 7+ messages in thread
From: Yoann Padioleau @ 2014-06-18 17:29 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hi,

In devcons.c there is

/*
 *  Put character, possibly a rune, into read queue at interrupt time.
 *  Called at interrupt time to process a character.
 */
int
kbdputc(Queue*, int ch)
{
	int i, n;
	char buf[3]; <----- enough?
	Rune r;
	char *next;

	if(kbd.ir == nil)
		return 0;		/* in case we're not inited yet */
	
	ilock(&kbd.lockputc);		/* just a mutex */
	r = ch;
	n = runetochar(buf, &r);
	for(i = 0; i < n; i++){
		next = kbd.iw+1;
		if(next >= kbd.ie)
			next = kbd.istage;
		if(next == kbd.ir)
			break;
		*kbd.iw = buf[i];
		kbd.iw = next;
	}
	iunlock(&kbd.lockputc);
	return 0;
}

But is the buf[3] enough? UTFMAX is 4 so we could possibly overflow no?
Shouldn't it be buf[UTFMAX] ?





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-18 18:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-18 17:29 [9fans] possible buffer overflow in devcons.c? Yoann Padioleau
2014-06-18 17:34 ` erik quanstrom
2014-06-18 17:34 ` andrey mirtchovski
2014-06-18 17:36   ` erik quanstrom
2014-06-18 18:13     ` Yoann Padioleau
2014-06-18 18:18       ` erik quanstrom
2014-06-18 18:44         ` erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).