git: ifconfig(8): Fix false -Wuse-after-free warnings in ifwg.c

Aaron LI aly at crater.dragonflybsd.org
Sat Oct 17 06:08:29 PDT 2026


commit a6e50c38bd6fa5d563e4587ae5dbce1cd41a49c7
Author: Aaron LI <aly at aaronly.me>
Date:   Fri Oct 16 17:44:34 2026 +0800

    ifconfig(8): Fix false -Wuse-after-free warnings in ifwg.c
    
    Tweak the code to fix the false -Wuse-after-free warnings in
    wg_data_grow() from GCC 12.5:
    
    ```
    /usr/src/sbin/ifconfig/ifwg.c: In function 'wg_data_grow':
    /usr/src/sbin/ifconfig/ifwg.c:79:20: warning: pointer may be used after 'realloc' [-Wuse-after-free]
       79 |         aip_offset = (char *)wg_aip - (char *)wg_interface;
          |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/src/sbin/ifconfig/ifwg.c:82:33: note: call to 'realloc' here
       82 |         wg_data.wgd_interface = realloc(wg_interface, wg_data.wgd_size);
          |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/src/sbin/ifconfig/ifwg.c:78:21: warning: pointer may be used after 'realloc' [-Wuse-after-free]
       78 |         peer_offset = (char *)wg_peer - (char *)wg_interface;
          |         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/src/sbin/ifconfig/ifwg.c:82:33: note: call to 'realloc' here
       82 |         wg_data.wgd_interface = realloc(wg_interface, wg_data.wgd_size);
          |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ```
    
    While there, tweak wg_data_init() a bit for consistency.

Summary of changes:
 sbin/ifconfig/ifwg.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/a6e50c38bd6fa5d563e4587ae5dbce1cd41a49c7


-- 
DragonFly BSD source repository


More information about the Commits mailing list