mirror of https://github.com/ericonr/sndio.git
test cookie perms
This commit is contained in:
parent
369b2b9faf
commit
2e3fe03333
|
@ -222,6 +222,10 @@ aucat_gencookie(unsigned char *cookie)
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (n == 0) {
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
cookie += n;
|
cookie += n;
|
||||||
len -= n;
|
len -= n;
|
||||||
}
|
}
|
||||||
|
@ -249,6 +253,7 @@ aucat_savecookie(char *path, unsigned char *cookie)
|
||||||
int
|
int
|
||||||
aucat_loadcookie(unsigned char *cookie)
|
aucat_loadcookie(unsigned char *cookie)
|
||||||
{
|
{
|
||||||
|
struct stat sb;
|
||||||
char buf[PATH_MAX], *path;
|
char buf[PATH_MAX], *path;
|
||||||
int fd, len, res;
|
int fd, len, res;
|
||||||
|
|
||||||
|
@ -266,6 +271,14 @@ aucat_loadcookie(unsigned char *cookie)
|
||||||
DPERROR(path);
|
DPERROR(path);
|
||||||
goto bad_gen;
|
goto bad_gen;
|
||||||
}
|
}
|
||||||
|
if (fstat(fd, &sb) < 0) {
|
||||||
|
DPERROR(path);
|
||||||
|
goto bad_close;
|
||||||
|
}
|
||||||
|
if (sb.st_mode & 0077) {
|
||||||
|
DPRINTF("%s has wrong permissions\n", path);
|
||||||
|
goto bad_close;
|
||||||
|
}
|
||||||
len = read(fd, cookie, AMSG_COOKIELEN);
|
len = read(fd, cookie, AMSG_COOKIELEN);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
DPERROR(path);
|
DPERROR(path);
|
||||||
|
|
Loading…
Reference in New Issue