Skip to content

Commit 04e362c

Browse files
committed
Fix strlen buffer overrun
1 parent 0d2c745 commit 04e362c

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

core/rtw_rf.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,12 +1050,8 @@ void rtw_txpwr_lmt_add_with_nlen(struct rf_ctl_t *rfctl, const char *regd_name,
10501050
ent = LIST_CONTAINOR(cur, struct txpwr_lmt_ent, list);
10511051
cur = get_next(cur);
10521052

1053-
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 1))
1054-
if (_rtw_memcmp(ent->regd_name, regd_name, nlen) == _TRUE)
1055-
#else
10561053
if (strlen(ent->regd_name) == nlen
10571054
&& _rtw_memcmp(ent->regd_name, regd_name, nlen) == _TRUE)
1058-
#endif
10591055
goto chk_lmt_val;
10601056
}
10611057

@@ -1229,7 +1225,7 @@ s8 rtw_rf_get_kfree_tx_gain_offset(_adapter *padapter, u8 path, u8 ch)
12291225
kfree_offset = kfree_data->bb_gain[bb_gain_sel][path];
12301226
if (IS_HARDWARE_TYPE_8723D(padapter))
12311227
RTW_INFO("%s path:%s, ch:%u, bb_gain_sel:%d, kfree_offset:%d\n"
1232-
, __func__, (path == 0)?"S1":"S0",
1228+
, __func__, (path == 0)?"S1":"S0",
12331229
ch, bb_gain_sel, kfree_offset);
12341230
else
12351231
RTW_INFO("%s path:%u, ch:%u, bb_gain_sel:%d, kfree_offset:%d\n"
@@ -1260,7 +1256,7 @@ void rtw_rf_set_tx_gain_offset(_adapter *adapter, u8 path, s8 offset)
12601256
target_path = path;
12611257
RTW_INFO("kfree gain_offset 0x55:0x%x ", rtw_hal_read_rfreg(adapter, target_path, 0x55, 0xffffffff));
12621258
}
1263-
1259+
12641260
switch (rtw_get_chip_type(adapter)) {
12651261
#ifdef CONFIG_RTL8723D
12661262
case RTL8723D:
@@ -1315,7 +1311,7 @@ void rtw_rf_set_tx_gain_offset(_adapter *adapter, u8 path, s8 offset)
13151311
rtw_warn_on(1);
13161312
break;
13171313
}
1318-
1314+
13191315
if (IS_HARDWARE_TYPE_8723D(adapter)) {
13201316
if (path == PPG_8723D_S1)
13211317
val32 = rtw_hal_read_rfreg(adapter, target_path, 0x55, 0xffffffff);

include/hal_data.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,12 @@ struct txpwr_lmt_ent {
332332
[MAX_TX_COUNT];
333333
#endif
334334

335-
char regd_name[0];
335+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 1))
336+
char regd_name[];
337+
#else
338+
char regd_name[0];
339+
#endif
340+
336341
};
337342
#endif /* CONFIG_TXPWR_LIMIT */
338343

include/rtw_rf.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,12 @@ struct regd_exc_ent {
173173
_list list;
174174
char country[2];
175175
u8 domain;
176-
char regd_name[0];
176+
177+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 1))
178+
char regd_name[];
179+
#else
180+
char regd_name[0];
181+
#endif
177182
};
178183

179184
void dump_regd_exc_list(void *sel, struct rf_ctl_t *rfctl);

0 commit comments

Comments
 (0)