Skip to content

Commit

Permalink
Merge pull request #334 from a1akris/fix/331/strlen
Browse files Browse the repository at this point in the history
Fix strlen buffer overrun
  • Loading branch information
tomaspinho authored Oct 1, 2023
2 parents 0d2c745 + a208875 commit b5b8a5c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 0 additions & 4 deletions core/rtw_rf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1050,12 +1050,8 @@ void rtw_txpwr_lmt_add_with_nlen(struct rf_ctl_t *rfctl, const char *regd_name,
ent = LIST_CONTAINOR(cur, struct txpwr_lmt_ent, list);
cur = get_next(cur);

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 1))
if (_rtw_memcmp(ent->regd_name, regd_name, nlen) == _TRUE)
#else
if (strlen(ent->regd_name) == nlen
&& _rtw_memcmp(ent->regd_name, regd_name, nlen) == _TRUE)
#endif
goto chk_lmt_val;
}

Expand Down
4 changes: 4 additions & 0 deletions include/hal_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,11 @@ struct txpwr_lmt_ent {
[MAX_TX_COUNT];
#endif

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
char regd_name[];
#else
char regd_name[0];
#endif
};
#endif /* CONFIG_TXPWR_LIMIT */

Expand Down
4 changes: 4 additions & 0 deletions include/rtw_rf.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ struct regd_exc_ent {
_list list;
char country[2];
u8 domain;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
char regd_name[];
#else
char regd_name[0];
#endif
};

void dump_regd_exc_list(void *sel, struct rf_ctl_t *rfctl);
Expand Down

0 comments on commit b5b8a5c

Please sign in to comment.