]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
kernel-pfroute: Fix kernel response handling
authorTobias Brunner <tobias@strongswan.org>
Tue, 19 Aug 2014 09:08:33 +0000 (11:08 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 19 Aug 2014 12:03:00 +0000 (14:03 +0200)
The condvar is signaled for every handled message received from the
kernel not only for replies (this changed with 2a2d7a4dc8).  This may
cause segfaults because this->reply is not set when the waiting thread is
woken due to an IP address change.

Since this->reply is only set when it is actually the expected reply (and
only one request is sent at a time, thanks to c9a323c1d9) we only have
to make sure the reply is there (and clear it once we handled it).

Using separate condvars could also be an option in the future.

src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c

index c4e8664f74fcfa284e073db06322b48a26597dfe..32157bbb4a581b7bb916212c2980892d3a878eab 100644 (file)
@@ -1518,8 +1518,7 @@ retry:
                        {       /* timed out? */
                                break;
                        }
-                       if (this->reply->rtm_msglen < sizeof(*this->reply) ||
-                               msg.hdr.rtm_seq != this->reply->rtm_seq)
+                       if (!this->reply)
                        {
                                continue;
                        }
@@ -1559,6 +1558,8 @@ retry:
        {
                failed = TRUE;
        }
+       free(this->reply);
+       this->reply = NULL;
        /* signal completion of query to a waiting thread */
        this->waiting_seq = 0;
        this->condvar->signal(this->condvar);