]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
RRDP: Patch deltas foreach
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Wed, 29 Sep 2021 00:01:00 +0000 (19:01 -0500)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Wed, 29 Sep 2021 00:01:00 +0000 (19:01 -0500)
The foreach was looping past the array limits.

Likely fixes #57.

src/rrdp/rrdp_objects.c
src/rrdp/rrdp_parser.c

index a885bf25b3d4d0f49fb978ff4dec967dd9828f7f..7898c30fa372cc344865578ad81c0e4905d2f6f2 100644 (file)
@@ -44,15 +44,15 @@ deltas_head_for_each(struct deltas_head *deltas, unsigned long max_serial,
        int error;
 
        /* No elements, send error so that the snapshot is processed */
-       if (deltas->capacity == 0) {
+       if (deltas->len == 0) {
                pr_val_warn("There's no delta list to process.");
                return -ENOENT;
        }
 
        pr_val_debug("Getting RRDP deltas from serial %lu to %lu.", from_serial,
            max_serial);
-       from = deltas->capacity - (max_serial - from_serial);
-       for (index = from; index < deltas->capacity; index++) {
+       from = deltas->len - (max_serial - from_serial);
+       for (index = from; index < deltas->len; index++) {
                error = cb(&deltas->array[index], arg);
                if (error)
                        return error;
index bc67c0e24d54756b2eb700a25b2105cc3baec625..889b73f8e01f5970cfb41ec71941f7140f0ea4c5 100644 (file)
@@ -905,7 +905,7 @@ process_delta(struct delta_head *delta_head, void *arg)
 
        head_data = &delta_head->doc_data;
 
-       pr_val_debug("Processing delta '%s'.", delta_head->doc_data.uri);
+       pr_val_debug("Processing delta '%s'.", head_data->uri);
        error = uri_create_https_str_rrdp(&uri, head_data->uri,
            strlen(head_data->uri));
        if (error)