Discussion:
[9fans] initdisplay() changes
(too old to reply)
c***@gmx.de
2013-01-25 13:01:09 UTC
Permalink
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
erik quanstrom
2013-01-25 15:16:38 UTC
Permalink
Post by c***@gmx.de
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;
if((n=read(ctlfd, info, sizeof info)) < 12){
close(ctlfd);
goto Error1;
}
if(n==NINFO+1)
n = NINFO;
--> buf[n] = '\0';
isnew = 0;
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;

Loading...