+2021-02-17 Timm Bäder <tbaeder@redhat.com>
+
+ * elflint.c (check_attributes): Rename and move left function...
+ (buffer_left): ...as static toplevel function taking both an
+ Elf_Data pointer argument and the unsigned char pointer p.
+
2021-02-17 Timm Bäder <tbaeder@redhat.com>
* elflint.c (check_attributes): Rename and move pos function...
return p - (const unsigned char *) data->d_buf;
}
+inline size_t
+buffer_left (Elf_Data *data, const unsigned char *p)
+{
+ return (const unsigned char *) data->d_buf + data->d_size - p;
+}
+
static void
check_attributes (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr, int idx)
{
return;
}
- inline size_t left (void)
- {
- return (const unsigned char *) data->d_buf + data->d_size - p;
- }
-
- while (left () >= 4)
+ while (buffer_left (data, p) >= 4)
{
uint32_t len;
memcpy (&len, p, sizeof len);
if (MY_ELFDATA != ehdr->e_ident[EI_DATA])
CONVERT (len);
- if (len > left ())
+ if (len > buffer_left (data, p))
{
ERROR (_("\
section [%2d] '%s': offset %zu: invalid length in attribute section\n"),
idx, section_name (ebl, idx), buffer_pos (data, p), name);
}
- if (left () != 0)
+ if (buffer_left (data, p) != 0)
ERROR (_("\
section [%2d] '%s': offset %zu: extra bytes after last attribute section\n"),
idx, section_name (ebl, idx), buffer_pos (data, p));