Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/net80211 Avoid using sprintf into an auto-sizing s...
details: https://anonhg.NetBSD.org/src-all/rev/bdef6703fd9d
branches: trunk
changeset: 375195:bdef6703fd9d
user: Martin Husemann <martin%NetBSD.org@localhost>
date: Tue Dec 14 21:19:26 2021 +0100
description:
Avoid using sprintf into an auto-sizing sbuf while holding a spin mutex.
diffstat:
sys/net80211/ieee80211.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diffs (20 lines):
diff -r 04d3c1be19ea -r bdef6703fd9d sys/net80211/ieee80211.c
--- a/sys/net80211/ieee80211.c Sun Dec 12 13:32:01 2021 +0100
+++ b/sys/net80211/ieee80211.c Tue Dec 14 21:19:26 2021 +0100
@@ -369,7 +369,15 @@ sysctl_ieee80211coms(SYSCTLFN_ARGS)
int error, len, cnt = 0;
RUN_ONCE(&ic_list_mtx_once, ic_list_mtx_init);
- sb = sbuf_new_auto();
+ mtx_lock(&ic_list_mtx);
+ len = 0;
+ LIST_FOREACH(ic, &ic_head, ic_next) {
+ if (len)
+ len++;
+ len += strlen(ic->ic_name);
+ }
+ mtx_unlock(&ic_list_mtx);
+ sb = sbuf_new(NULL, NULL, len+20 /* some slope */, 0);
mtx_lock(&ic_list_mtx);
LIST_FOREACH(ic, &ic_head, ic_next) {
sbuf_printf(sb, "%s%s", sp, ic->ic_name);
Home |
Main Index |
Thread Index |
Old Index