]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Free anything we alloc in mod_decode if decoding the detail entry fails
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 30 May 2018 15:11:37 +0000 (21:11 +0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 30 May 2018 15:16:51 +0000 (21:16 +0600)
Not strictly necessary but usually a good thing to do

src/modules/proto_detail/proto_detail.c

index fe239597cdac1fd78086bb15eb38818a09735ed3..5eee8b314b44f29fba916542b5d730c4d8090677 100644 (file)
@@ -250,7 +250,7 @@ static int mod_decode(void const *instance, REQUEST *request, uint8_t *const dat
        MPRINT("HEADER %s", data);
 
        if (sscanf((char const *) data, "%*s %*s %*d %*d:%*d:%*d %d", &num) != 1) {
-               RDEBUG("Malformed header '%s'", (char const *) data);
+               REDEBUG("Malformed header '%s'", (char const *) data);
                return -1;
        }
 
@@ -263,6 +263,7 @@ static int mod_decode(void const *instance, REQUEST *request, uint8_t *const dat
 
        lineno = 1;
        fr_cursor_init(&cursor, &request->packet->vps);
+       fr_cursor_tail(&cursor);        /* Ensure we only free what we add on error */
 
        /*
         *      Parse each individual line.
@@ -281,7 +282,8 @@ static int mod_decode(void const *instance, REQUEST *request, uint8_t *const dat
                 *      doesn't hurt to re-check it here.
                 */
                if ((*p != '\0') && (*p != '\t')) {
-                       RDEBUG("Malformed line %d", lineno);
+                       REDEBUG("Malformed line %d", lineno);
+                       fr_cursor_free_list(&cursor);
                        return -1;
                }