]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - sync_filter.c
string: Introduce arr_realloc() and check for integer overflow.
[paraslash.git] / sync_filter.c
index efc10116f788a79bee5e2e75dfdfc0e036d06f1a..9c1767e41aaa4cd65c790a48ed6078cf98d43aaf 100644 (file)
@@ -1,8 +1,4 @@
-/*
- * Copyright (C) 2013 Andre Noll <maan@tuebingen.mpg.de>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2013 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
 
 /** \file sync_filter.c Playback synchronization filter. */
 
@@ -106,8 +102,8 @@ static void sync_open(struct filter_node *fn)
        unsigned buddy_given;
        const struct lls_opt_result *r_b;
 
-       ctx = fn->private_data = para_calloc(sizeof(*ctx));
-       INIT_LIST_HEAD(&ctx->buddies);
+       ctx = fn->private_data = zalloc(sizeof(*ctx));
+       init_list_head(&ctx->buddies);
 
        /* create socket to listen for incoming packets */
        ret = makesock(
@@ -152,7 +148,7 @@ static void sync_open(struct filter_node *fn)
                        close(fd);
                        goto fail;
                }
-               buddy = para_malloc(sizeof(*buddy));
+               buddy = alloc(sizeof(*buddy));
                buddy->fd = fd;
                buddy->sbi = sbi + i;
                buddy->ping_received = false;
@@ -180,12 +176,12 @@ static void *sync_setup(const struct lls_parse_result *lpr)
 
        r_b = FILTER_CMD_OPT_RESULT(SYNC, BUDDY, lpr);
        n = lls_opt_given(r_b);
-       sbi = para_malloc(n * sizeof(*sbi));
+       sbi = alloc(n * sizeof(*sbi));
        PARA_INFO_LOG("initializing buddy info array of length %u\n", n);
        for (i = 0; i < n; i++) {
                const char *url = lls_string_val(i, r_b);
                size_t len = strlen(url);
-               char *host = para_malloc(len + 1);
+               char *host = alloc(len + 1);
                int port;
                struct addrinfo *ai;
 
@@ -369,7 +365,8 @@ success:
        ret = -E_SYNC_COMPLETE; /* success */
        goto out;
 fail:
-       PARA_WARNING_LOG("%s\n", para_strerror(-ret));
+       if (ret != -E_BTR_EOF)
+               PARA_WARNING_LOG("%s\n", para_strerror(-ret));
 out:
        sync_close_buddies(ctx);
        btr_splice_out_node(&fn->btrn);