rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | From 471f7e4e72feea16f06d806c47b05719c3d77d8f Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Tue, 25 Apr 2017 15:57:33 -0700 |
| 4 | Subject: [PATCH 2/2] Fix printf overflow warnings |
| 5 | |
| 6 | Fixes |
| 7 | |
| 8 | ../../elfutils-0.148/src/ar.c:865:49: error: '__builtin___snprintf_chk' output truncated before the last format character [-Werror=format-truncation=] |
| 9 | snprintf (tmpbuf, sizeof (tmpbuf), "/%-*ld", |
| 10 | ^ |
| 11 | In file included from /mnt/a/build/tmp-glibc/work/cortexa7hf-neon-vfpv4-oe-linux-gnueabi/elfutils/0.148-r11/recipe-sysroot/usr/include/stdio.h:889:0, |
| 12 | from /mnt/a/build/tmp-glibc/work/cortexa7hf-neon-vfpv4-oe-linux-gnueabi/elfutils/0.148-r11/recipe-sysroot/usr/include/argp.h:23, |
| 13 | from ../../elfutils-0.148/src/ar.c:30: |
| 14 | /mnt/a/build/tmp-glibc/work/cortexa7hf-neon-vfpv4-oe-linux-gnueabi/elfutils/0.148-r11/recipe-sysroot/usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output 18 b |
| 15 | ytes into a destination of size 17 |
| 16 | |
| 17 | Upstream-Status: Pending |
| 18 | |
| 19 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 20 | --- |
| 21 | src/ar.c | 6 +++--- |
| 22 | 1 file changed, 3 insertions(+), 3 deletions(-) |
| 23 | |
| 24 | diff --git a/src/ar.c b/src/ar.c |
| 25 | index 8e2abbe..0bf5051 100644 |
| 26 | --- a/src/ar.c |
| 27 | +++ b/src/ar.c |
| 28 | @@ -853,7 +853,7 @@ write_member (struct armem *memb, off_t *startp, off_t *lenp, Elf *elf, |
| 29 | off_t end_off, int newfd) |
| 30 | { |
| 31 | struct ar_hdr arhdr; |
| 32 | - char tmpbuf[sizeof (arhdr.ar_name) + 1]; |
| 33 | + char tmpbuf[sizeof (arhdr.ar_name) + 2]; |
| 34 | |
| 35 | bool changed_header = memb->long_name_off != -1; |
| 36 | if (changed_header) |
| 37 | @@ -1454,7 +1454,7 @@ do_oper_insert (int oper, const char *arfname, char **argv, int argc, |
| 38 | |
| 39 | /* Create the header. */ |
| 40 | struct ar_hdr arhdr; |
| 41 | - char tmpbuf[sizeof (arhdr.ar_name) + 1]; |
| 42 | + char tmpbuf[sizeof (arhdr.ar_name) + 2]; |
| 43 | if (all->long_name_off == -1) |
| 44 | { |
| 45 | size_t namelen = strlen (all->name); |
| 46 | @@ -1464,7 +1464,7 @@ do_oper_insert (int oper, const char *arfname, char **argv, int argc, |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | - snprintf (tmpbuf, sizeof (arhdr.ar_name) + 1, "/%-*ld", |
| 51 | + snprintf (tmpbuf, sizeof (tmpbuf), "/%-*ld", |
| 52 | (int) sizeof (arhdr.ar_name), all->long_name_off); |
| 53 | memcpy (arhdr.ar_name, tmpbuf, sizeof (arhdr.ar_name)); |
| 54 | } |
| 55 | -- |
| 56 | 2.12.2 |
| 57 | |