Date: Mon, 26 Jun 2023 16:30:39 GMT From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 6403f0ac1281 - stable/13 - seq: fix potential NULL ptr reference Message-ID: <202306261630.35QGUdRk025491@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=6403f0ac1281a9f95f387c98ef17f88f59714e56 commit 6403f0ac1281a9f95f387c98ef17f88f59714e56 Author: Mariusz Zaborski <oshogbo@FreeBSD.org> AuthorDate: 2022-09-30 17:36:04 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2023-06-26 16:30:31 +0000 seq: fix potential NULL ptr reference asprintf(3) allocates memory, and there isn't any guarantee of success. MFC after: 2 weeks Obtained from: OpenBSD (cherry picked from commit 94c4f663bab58ec07584786dd76866011d5b2506) --- usr.bin/seq/seq.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usr.bin/seq/seq.c b/usr.bin/seq/seq.c index 7559dbd9ce20..47ba0b7ce3af 100644 --- a/usr.bin/seq/seq.c +++ b/usr.bin/seq/seq.c @@ -199,8 +199,12 @@ main(int argc, char *argv[]) * loop held true due to a rounding error and we still need to print * 'last'. */ - asprintf(&cur_print, fmt, cur); - asprintf(&last_print, fmt, last); + if (asprintf(&cur_print, fmt, cur) < 0) { + err(1, "asprintf"); + } + if (asprintf(&last_print, fmt, last) < 0) { + err(1, "asprintf"); + } if (strcmp(cur_print, last_print) == 0 && cur != last_shown_value) { fputs(last_print, stdout); fputs(sep, stdout);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202306261630.35QGUdRk025491>