9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] initdisplay() changes
@ 2013-01-25 13:01 cinap_lenrek
  2013-01-25 15:16 ` erik quanstrom
  0 siblings, 1 reply; 2+ messages in thread
From: cinap_lenrek @ 2013-01-25 13:01 UTC (permalink / raw)
  To: 9fans

the latest changes in libdraw:

 Display*
 initdisplay(char *dev, char *win, void(*error)(Display*, char*))
 {
-	char buf[128], info[NINFO+1], *t, isnew;
+	char buf[NINFO+1], info[NINFO+1], *t, isnew;

this is wrong. the real bug is here:

	if((n=read(ctlfd, info, sizeof info)) < 12){
    Error2:
		close(ctlfd);
		goto Error1;
	}
	if(n==NINFO+1)
		n = NINFO;
-->	buf[n] = '\0';
	isnew = 0;

that should be:

info[n] = '\0';

--
cinap



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

* Re: [9fans] initdisplay() changes
  2013-01-25 13:01 [9fans] initdisplay() changes cinap_lenrek
@ 2013-01-25 15:16 ` erik quanstrom
  0 siblings, 0 replies; 2+ messages in thread
From: erik quanstrom @ 2013-01-25 15:16 UTC (permalink / raw)
  To: 9fans

On Fri Jan 25 08:07:59 EST 2013, cinap_lenrek@gmx.de wrote:
> the latest changes in libdraw:
>
>  Display*
>  initdisplay(char *dev, char *win, void(*error)(Display*, char*))
>  {
> -	char buf[128], info[NINFO+1], *t, isnew;
> +	char buf[NINFO+1], info[NINFO+1], *t, isnew;
>
> this is wrong. the real bug is here:
>
> 	if((n=read(ctlfd, info, sizeof info)) < 12){
>     Error2:
> 		close(ctlfd);
> 		goto Error1;
> 	}
> 	if(n==NINFO+1)
> 		n = NINFO;
> -->	buf[n] = '\0';
> 	isnew = 0;
>
> that should be:
>
> info[n] = '\0';

you're right.  i think this is what i should have said:

; 9diff init.c
/n/sources/plan9/sys/src/libdraw/init.c:200,206 - init.c:200,206
  Display*
  initdisplay(char *dev, char *win, void(*error)(Display*, char*))
  {
- 	char buf[NINFO+1], info[NINFO+1], *t, isnew;
+ 	char buf[128], info[NINFO+1], *t, isnew;
  	int n, datafd, ctlfd, reffd;
  	Display *disp;
  	Dir *dir;
/n/sources/plan9/sys/src/libdraw/init.c:240,246 - init.c:240,246
  	}
  	if(n==NINFO+1)
  		n = NINFO;
- 	buf[n] = '\0';
+ 	info[n] = '\0';
  	isnew = 0;
  	if(n < NINFO)	/* this will do for now, we need something better here */
  		isnew = 1;



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

end of thread, other threads:[~2013-01-25 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-25 13:01 [9fans] initdisplay() changes cinap_lenrek
2013-01-25 15:16 ` 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).