freedreno/cffdec: Fix format overflow warning.
authorEric Anholt <eric@anholt.net>
Mon, 19 Oct 2020 18:41:57 +0000 (11:41 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 20 Oct 2020 22:16:59 +0000 (22:16 +0000)
../src/freedreno/decode/cffdec.c: In function ‘reg_disasm_gpuaddr’:
../src/freedreno/decode/cffdec.c:404:29: error: ‘sprintf’ writing a
terminating nul past the end of the destination [-Werror=format-overflow=]
  404 |   sprintf(filename, "%04d.%s", n++, ext);
../src/freedreno/decode/cffdec.c:404:3: note: ‘sprintf’ output between
9 and 16 bytes into a destination of size 8
  404 |   sprintf(filename, "%04d.%s", n++, ext);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7224>

src/freedreno/decode/cffdec.c

index ed9537a..10b27b0 100644 (file)
@@ -399,7 +399,7 @@ dump_shader(const char *ext, void *buf, int bufsz)
 {
        if (options->dump_shaders) {
                static int n = 0;
-               char filename[8];
+               char filename[16];
                int fd;
                sprintf(filename, "%04d.%s", n++, ext);
                fd = open(filename, O_WRONLY| O_TRUNC | O_CREAT, 0644);