aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorEvyatar Stalinsky <evyatar@stalinsky.xyz>2023-06-29 15:58:56 +0300
committerEvyatar Stalinsky <evyatar@stalinsky.xyz>2023-06-29 15:58:56 +0300
commit21e96c459d75b81216c4047d9ec418985d0f0e00 (patch)
treec848f209c586ff248b2bedb452f738563352b5e3 /util
parentc68c9f1685e41082679abdf3ae181a21d0e0fc9a (diff)
util/log: fix buffer overflow
Diffstat (limited to 'util')
-rw-r--r--util/log.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/util/log.c b/util/log.c
index cbec3e86..ae84f7e7 100644
--- a/util/log.c
+++ b/util/log.c
@@ -72,8 +72,9 @@ static wlr_log_func_t log_callback = log_stderr;
static void log_wl(const char *fmt, va_list args) {
static char wlr_fmt[1024];
int n = snprintf(wlr_fmt, sizeof(wlr_fmt), "[wayland] %s", fmt);
- if (n > 0 && wlr_fmt[n - 1] == '\n') {
- wlr_fmt[n - 1] = '\0';
+ size_t len = strlen(wlr_fmt);
+ if (n > 0 && wlr_fmt[len - 1] == '\n') {
+ wlr_fmt[len - 1] = '\0';
}
_wlr_vlog(WLR_INFO, wlr_fmt, args);
}