On Fri Jan 25 08:07:59 EST 2013, [email protected] 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;

Reply via email to