Found a small todo item in proc_parser() to free the entries in the auth
and crl trees.

OK?

Kind regards,

Job

Index: cert.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/cert.c,v
retrieving revision 1.88
diff -u -p -r1.88 cert.c
--- cert.c      3 Sep 2022 14:40:09 -0000       1.88
+++ cert.c      3 Sep 2022 20:34:19 -0000
@@ -976,7 +976,7 @@ authcmp(struct auth *a, struct auth *b)
        return strcmp(a->cert->ski, b->cert->ski);
 }
 
-RB_GENERATE_STATIC(auth_tree, auth, entry, authcmp);
+RB_GENERATE(auth_tree, auth, entry, authcmp);
 
 struct auth *
 auth_find(struct auth_tree *auths, const char *aki)
Index: crl.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/crl.c,v
retrieving revision 1.15
diff -u -p -r1.15 crl.c
--- crl.c       21 Apr 2022 09:53:07 -0000      1.15
+++ crl.c       3 Sep 2022 20:34:19 -0000
@@ -87,7 +87,7 @@ crlcmp(struct crl *a, struct crl *b)
        return strcmp(a->aki, b->aki);
 }
 
-RB_GENERATE_STATIC(crl_tree, crl, entry, crlcmp);
+RB_GENERATE(crl_tree, crl, entry, crlcmp);
 
 /*
  * Find a CRL based on the auth SKI value.
Index: extern.h
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/extern.h,v
retrieving revision 1.155
diff -u -p -r1.155 extern.h
--- extern.h    3 Sep 2022 14:40:09 -0000       1.155
+++ extern.h    3 Sep 2022 20:34:20 -0000
@@ -372,6 +372,7 @@ struct crl {
  * Tree of CRLs sorted by uri
  */
 RB_HEAD(crl_tree, crl);
+RB_PROTOTYPE(crl_tree, crl, entry, crlcmp);
 
 /*
  * An authentication tuple.
@@ -387,6 +388,7 @@ struct auth {
  * Tree of auth sorted by ski
  */
 RB_HEAD(auth_tree, auth);
+RB_PROTOTYPE(auth_tree, auth, entry, authcmp);
 
 struct auth    *auth_find(struct auth_tree *, const char *);
 struct auth    *auth_insert(struct auth_tree *, struct cert *, struct auth *);
Index: parser.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/parser.c,v
retrieving revision 1.76
diff -u -p -r1.76 parser.c
--- parser.c    3 Sep 2022 13:30:27 -0000       1.76
+++ parser.c    3 Sep 2022 20:34:20 -0000
@@ -675,6 +675,8 @@ proc_parser(int fd)
        struct pollfd    pfd;
        struct entity   *entp;
        struct ibuf     *b, *inbuf = NULL;
+       struct auth     *auth, *tauth;
+       struct crl      *crl, *tcrl;
 
        /* Only allow access to the cache directory. */
        if (unveil(".", "r") == -1)
@@ -744,7 +746,15 @@ proc_parser(int fd)
                entity_free(entp);
        }
 
-       /* XXX free auths and crl tree */
+       RB_FOREACH_SAFE(auth, auth_tree, &auths, tauth) {
+               RB_REMOVE(auth_tree, &auths, auth);
+               free(auth);
+       }
+
+       RB_FOREACH_SAFE(crl, crl_tree, &crlt, tcrl) {
+               RB_REMOVE(crl_tree, &crlt, crl);
+               free(crl);
+       }
 
        X509_STORE_CTX_free(ctx);
        msgbuf_clear(&msgq);

Reply via email to