+2015-05-17 Mark Wielaard <mjw@redhat.com>
+
+ * eblopenbackend.c (MAX_PREFIX_LEN): New define (16).
+ (openbackend): Stack allocate symname array using MAX_PREFIX_LEN.
+
2015-01-27 Mark Wielaard <mjw@redhat.com>
* libebl.h: Add comment from README that this is completely
/* Generate ELF backend handle.
- Copyright (C) 2000-2014 Red Hat, Inc.
+ Copyright (C) 2000-2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
};
#define nmachines (sizeof (machines) / sizeof (machines[0]))
+/* No machine prefix should be larger than this. */
+#define MAX_PREFIX_LEN 16
/* Default callbacks. Mostly they just return the error value. */
static const char *default_object_type_name (int ignore, char *buf,
static const char version[] = MODVERSION;
const char *modversion;
ebl_bhinit_t initp;
- char symname[machines[cnt].prefix_len + sizeof "_init"];
+
+ // We use a static number to help the compiler see we don't
+ // overflow the stack with an arbitrary number.
+ assert (machines[cnt].prefix_len <= MAX_PREFIX_LEN);
+ char symname[MAX_PREFIX_LEN + sizeof "_init"];
strcpy (mempcpy (symname, machines[cnt].prefix,
machines[cnt].prefix_len), "_init");