libdraw: use readn() to read headers and Fontchar array

the Fontchar array might be bigger than the i/o unit,
so we have to use readn() to properly read it.
front
cinap_lenrek 2015-03-01 05:39:45 +01:00
parent 7cdc13accc
commit e725771b5d
2 changed files with 4 additions and 4 deletions

View File

@ -19,7 +19,7 @@ readsubfonti(Display*d, char *name, int fd, Image *ai, int dolock)
return nil;
}
p = nil;
if(read(fd, hdr, 3*12) != 3*12){
if(readn(fd, hdr, 3*12) != 3*12){
werrstr("readsubfont: header read error: %r");
goto Err;
}
@ -31,7 +31,7 @@ readsubfonti(Display*d, char *name, int fd, Image *ai, int dolock)
p = malloc(6*(n+1));
if(p == nil)
goto Err;
if(read(fd, p, 6*(n+1)) != 6*(n+1)){
if(readn(fd, p, 6*(n+1)) != 6*(n+1)){
werrstr("readsubfont: fontchar read error: %r");
goto Err;
}

View File

@ -20,7 +20,7 @@ openmemsubfont(char *name)
i = readmemimage(fd);
if(i == nil)
goto Err;
if(read(fd, hdr, 3*12) != 3*12){
if(readn(fd, hdr, 3*12) != 3*12){
werrstr("openmemsubfont: header read error: %r");
goto Err;
}
@ -32,7 +32,7 @@ openmemsubfont(char *name)
p = malloc(6*(n+1));
if(p == nil)
goto Err;
if(read(fd, p, 6*(n+1)) != 6*(n+1)){
if(readn(fd, p, 6*(n+1)) != 6*(n+1)){
werrstr("openmemsubfont: fontchar read error: %r");
goto Err;
}