Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Apr 2024 19:43:05 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 56ee5fc43c40 - main - rtld snprintf: do not erronously skip a char at the buffer boundary
Message-ID:  <202404281943.43SJh5Ip061927@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=56ee5fc43c40479e2651b21862e299bcf73017ae

commit 56ee5fc43c40479e2651b21862e299bcf73017ae
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-04-28 06:37:24 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-04-28 19:42:12 +0000

    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
---
 libexec/rtld-elf/rtld_printf.c | 7 +++----
 1 file 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;
 	}
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404281943.43SJh5Ip061927>