git: 392611f28695 - stable/13 - imgact_elf: compute auxv buffer size instead of using magic value

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 12 May 2022 22:56:27 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=392611f2869573cc41551d5b6c6504f8e604d163

commit 392611f2869573cc41551d5b6c6504f8e604d163
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-06-21 14:34:19 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-12 22:12:59 +0000

    imgact_elf: compute auxv buffer size instead of using magic value
    
    The new buffer is somewhat larger, but there should be no functional
    changes.
    
    Reviewed By:    kib, imp
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D30821
    
    (cherry picked from commit 06250515cff552217d14145e8932cb1a543a7e07)
---
 sys/kern/imgact_elf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index d189339283a7..1732b0dbe23d 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -2526,7 +2526,8 @@ __elfN(note_procstat_auxv)(void *arg, struct sbuf *sb, size_t *sizep)
 	p = (struct proc *)arg;
 	if (sb == NULL) {
 		size = 0;
-		sb = sbuf_new(NULL, NULL, 128, SBUF_FIXEDLEN);
+		sb = sbuf_new(NULL, NULL, AT_COUNT * sizeof(Elf_Auxinfo),
+		    SBUF_FIXEDLEN);
 		sbuf_set_drain(sb, sbuf_count_drain, &size);
 		sbuf_bcat(sb, &structsize, sizeof(structsize));
 		PHOLD(p);