Fri Feb 16 18:23:15 IST 2007 Mark McLoughlin <markmc@redhat.com>

* qemud/qemud.c: fix qemudEnableIpForwarding() to not leak
        an fd if writing to /proc/sys/net/ipv4/ip_forward fails.
This commit is contained in:
Mark McLoughlin 2007-02-16 18:24:14 +00:00
parent 1b350c101b
commit 80820ec7a9
2 changed files with 13 additions and 6 deletions

View File

@ -1,3 +1,8 @@
Fri Feb 16 18:23:15 IST 2007 Mark McLoughlin <markmc@redhat.com>
* qemud/qemud.c: fix qemudEnableIpForwarding() to not leak
an fd if writing to /proc/sys/net/ipv4/ip_forward fails.
Fri Feb 16 11:56:24 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* tests/Makefile.am: Fixed linkage of test suites

View File

@ -980,15 +980,17 @@ qemudEnableIpForwarding(void)
{
#define PROC_IP_FORWARD "/proc/sys/net/ipv4/ip_forward"
int fd;
int fd, ret;
if ((fd = open(PROC_IP_FORWARD, O_WRONLY|O_TRUNC)) == -1 ||
write(fd, "1\n", 2) < 0)
return 0;
if ((fd = open(PROC_IP_FORWARD, O_WRONLY|O_TRUNC)) == -1)
return 0;
close (fd);
if (write(fd, "1\n", 2) < 0)
ret = 0;
return 1;
close (fd);
return 1;
#undef PROC_IP_FORWARD
}