ipc: do not use fscanf with trailing \n
If the stream is not closed, then this winds up hanging forever. So remove the trailing \n\n and check manually after. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
66ed611bd0
commit
457f96b65e
|
@ -92,8 +92,10 @@ static int userspace_set_device(struct wgdevice *dev)
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
fflush(f);
|
fflush(f);
|
||||||
|
|
||||||
if (fscanf(f, "errno=%d\n\n", &ret) != 1)
|
if (fscanf(f, "errno=%d", &ret) != 1)
|
||||||
ret = errno ? -errno : -EPROTO;
|
ret = errno ? -errno : -EPROTO;
|
||||||
|
if (getc(f) != '\n' || getc(f) != '\n')
|
||||||
|
ret = -EPROTO;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
errno = -ret;
|
errno = -ret;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Reference in New Issue