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> Fri Feb 16 11:56:24 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* tests/Makefile.am: Fixed linkage of test suites * tests/Makefile.am: Fixed linkage of test suites

View File

@ -980,12 +980,14 @@ qemudEnableIpForwarding(void)
{ {
#define PROC_IP_FORWARD "/proc/sys/net/ipv4/ip_forward" #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 || if ((fd = open(PROC_IP_FORWARD, O_WRONLY|O_TRUNC)) == -1)
write(fd, "1\n", 2) < 0)
return 0; return 0;
if (write(fd, "1\n", 2) < 0)
ret = 0;
close (fd); close (fd);
return 1; return 1;