aboutsummaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2024-04-28 06:37:24 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2024-04-28 19:42:12 +0000
commit56ee5fc43c40479e2651b21862e299bcf73017ae (patch)
treebb8c4a425ecdf9a30fd79e98ea40cf756c2f46a5 /libexec
parent6662c2312e956439652ce2d06b42753b6a78fc61 (diff)
downloadsrc-56ee5fc43c40479e2651b21862e299bcf73017ae.tar.gz
src-56ee5fc43c40479e2651b21862e299bcf73017ae.zip
rtld snprintf: do not erronously skip a char at the buffer boundary
Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44987
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/rtld_printf.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libexec/rtld-elf/rtld_printf.c b/libexec/rtld-elf/rtld_printf.c
index 07598c73c6d4..befac1c547b7 100644
--- a/libexec/rtld-elf/rtld_printf.c
+++ b/libexec/rtld-elf/rtld_printf.c
@@ -81,11 +81,10 @@ snprintf_func(int ch, struct snprintf_arg *const info)
}
break;
case PRINT_METHOD_WRITE:
- if (info->remain > 0) {
- *info->str++ = ch;
- info->remain--;
- } else
+ if (info->remain == 0)
printf_out(info);
+ *info->str++ = ch;
+ info->remain--;
break;
}
}