]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: Fix sanity check of DW_FORM_block length in print_cfa_program
authorMark Wielaard <mjw@redhat.com>
Tue, 18 Nov 2014 09:01:48 +0000 (10:01 +0100)
committerMark Wielaard <mjw@redhat.com>
Tue, 18 Nov 2014 09:01:48 +0000 (10:01 +0100)
We were checking the reg nr, not the length of the block.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/readelf.c

index c14bfb66c47ca2a4c86f74d07663c593b9812bcb..08de79891dd0ecef9a3935cef70967c49a7aeedd 100644 (file)
@@ -5025,7 +5025,7 @@ print_cfa_program (const unsigned char *readp, const unsigned char *const endp,
            get_uleb128 (op2, readp);   /* Length of DW_FORM_block.  */
            printf ("     expression r%" PRIu64 " (%s) \n",
                    op1, regname (op1));
-           if ((uint64_t) (endp - readp) < op1)
+           if ((uint64_t) (endp - readp) < op2)
              goto invalid;
            print_ops (dwflmod, dbg, 10, 10, version, ptr_size, 0, NULL,
                       op2, readp);