Dwarves Archive on lore.kernel.org
 help / color / Atom feed
* Segfault in latest pahole
@ 2008-12-19 14:21 Emmanuel Viaud
  0 siblings, 0 replies; only message in thread
From: Emmanuel Viaud @ 2008-12-19 14:21 UTC (permalink / raw)
  To: dwarves-u79uwXL29TY76Z2rM5mHXA

Hi.

I got a segfault using latest head of pahole. The problems comes from
the memcpy call in gobuffer_add function when the entry to add has a
size larger than GOBUFFER__BCHUNK (the entry was 16299 bytes long in
my example). In that case, the realloc (which only allocates
GOBUFFER_BCHUNK bytes) does not allocate enough memory.

The simple following patch solves my problem, but I don't know if it
is good enough:
diff --git a/gobuffer.c b/gobuffer.c
index 5797aa6..d3f4726 100644
--- a/gobuffer.c
+++ b/gobuffer.c
@@ -63,7 +63,7 @@ unsigned int gobuffer__add(struct gobuffer *self,
const void *s,
        const unsigned int index = self->index + len;
        char *copy;

-       if (index >= self->allocated_size) {
+    while (index >= self->allocated_size) {
                const unsigned int allocated_size = (self->allocated_size +
                                                     GOBUFFER__BCHUNK);
                char *entries = realloc(self->entries, allocated_size);

Thanks and best regards.
Emmanuel
--
To unsubscribe from this list: send the line "unsubscribe dwarves" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-19 14:21 Segfault in latest pahole Emmanuel Viaud

Dwarves Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dwarves/0 dwarves/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dwarves dwarves/ https://lore.kernel.org/dwarves \
		dwarves@vger.kernel.org
	public-inbox-index dwarves

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.dwarves


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git