Skip to content

Commit cf51aeb

Browse files
AlphixNoltari
authored andcommitted
odhcpd: fix captive_portal_uri reset
odhcpd_reload() calls clean_interface() which does a memset() on the given struct iface from iface->ra onwards, so captive_portal_uri and captive_portal_uri_len have to be below iface->ra in order to be zeroed on reload. Otherwise, iface->captive_portal_uri will be free():d, but iface->captive_portal_uri_len could still be > 0. This is a bit of a footgun (one wouldn't normally expect the order of struct members to matter), and should probably be dealt with in a more thorough manner, but I've just done the minimum and added a warning in src/odhcpd.h for now, Signed-off-by: David Härdeman <david@hardeman.nu> Link: openwrt#345 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
1 parent e8b7fde commit cf51aeb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/odhcpd.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,7 @@ struct interface {
391391
struct avl_tree dhcpv4_leases;
392392
struct list_head dhcpv4_fr_ips;
393393

394-
// RFC8910
395-
char *captive_portal_uri;
396-
size_t captive_portal_uri_len;
394+
/* NOTE: everything from this point is zeroed on odhcpd_reload() */
397395

398396
// Services
399397
enum odhcpd_mode ra;
@@ -494,6 +492,10 @@ struct interface {
494492
struct ra_pio *pios;
495493
size_t pio_cnt;
496494
bool pio_update;
495+
496+
// RFC8910
497+
char *captive_portal_uri;
498+
size_t captive_portal_uri_len;
497499
};
498500

499501
extern struct avl_tree interfaces;

0 commit comments

Comments
 (0)