]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
we should pretty much NEVER use "*++p". Instead, use *(p++)
authorAlan T. DeKok <aland@freeradius.org>
Tue, 31 Mar 2020 13:46:30 +0000 (09:46 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 31 Mar 2020 13:46:30 +0000 (09:46 -0400)
The first one increments 'p' BEFORE assigning.  Which results
in uninitialized memory.

The second on increments 'p' AFTER assigning.  Which is what we want

src/protocols/internal/encode.c

index f733ece86051b4ae924c4439ec494f33d767611c..f9a68d11f3935123ee3c3d18d5e5e6e23244677f 100644 (file)
@@ -55,7 +55,7 @@ static ssize_t internal_encode(uint8_t *out, size_t outlen,
        /*
         *      Zero out 'enc_field'
         */
-       *++p = 0x00;
+       *(p++) = 0x00;
 
        /*
         *      Ensure we have at least enough space
@@ -81,7 +81,7 @@ static ssize_t internal_encode(uint8_t *out, size_t outlen,
         *      Need to use the second encoding byte
         */
        if (da->flags.is_unknown) {
-               *++p = 0x00;
+               *(p++) = 0x00;
                FR_PAIR_ENCODE_HAVE_SPACE(p, end, (sizeof(uint64_t) * 2) + 2);  /* Check we still have room */
 
                enc_field[0] |= FR_INTERNAL_FLAG_EXTENDED;