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/887d1ed1a337
branches: trunk
changeset: 377957:887d1ed1a337
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 d7767e2424ee -r 887d1ed1a337 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