linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3] Fix core dump on huge switch
@ 2007-02-10  0:16 Christopher Li
  2007-02-26 19:57 ` Josh Triplett
  0 siblings, 1 reply; 2+ messages in thread
From: Christopher Li @ 2007-02-10  0:16 UTC (permalink / raw)
  To: linux-sparse; +Cc: Josh Triplett

Bump up the size of the instruction buffer. vt_ioctl.c has
a huge switch statement causing sparse over flow the instruction
buffer.

Signed-Off-By: Christopher Li <sparse@chrisli.org>

Index: sparse/linearize.c
===================================================================
--- sparse.orig/linearize.c	2007-01-30 20:07:40.000000000 -0800
+++ sparse/linearize.c	2007-01-30 20:48:16.000000000 -0800
@@ -272,7 +272,7 @@ static char *show_asm(char *buf, struct 
 const char *show_instruction(struct instruction *insn)
 {
 	int opcode = insn->opcode;
-	static char buffer[1024];
+	static char buffer[4096];
 	char *buf;
 
 	buf = buffer;
@@ -457,6 +457,9 @@ const char *show_instruction(struct inst
 	default:
 		break;
 	}
+
+	if (buf >= buffer + sizeof buffer)
+		die("instruction buffer overflowed %d\n", buf - buffer);
 	do { --buf; } while (*buf == ' ');
 	*++buf = 0;
 	return buffer;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 3] Fix core dump on huge switch
  2007-02-10  0:16 [PATCH 3] Fix core dump on huge switch Christopher Li
@ 2007-02-26 19:57 ` Josh Triplett
  0 siblings, 0 replies; 2+ messages in thread
From: Josh Triplett @ 2007-02-26 19:57 UTC (permalink / raw)
  To: Christopher Li; +Cc: linux-sparse

[-- Attachment #1: Type: text/plain, Size: 587 bytes --]

Christopher Li wrote:
> Bump up the size of the instruction buffer. vt_ioctl.c has
> a huge switch statement causing sparse over flow the instruction
> buffer.
> 
> Signed-Off-By: Christopher Li <sparse@chrisli.org>

I've applied this fix for now, to solve the immediate problem; thanks for the patch.  

Ideally I'd like to see some solution that grows the buffer as needed.

I also committed one minor style fix after your patch:

> +	if (buf >= buffer + sizeof buffer)

Please use parentheses with sizeof, per the Linux Documentation/CodingStyle.

- Josh Triplett


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-26 19:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-10  0:16 [PATCH 3] Fix core dump on huge switch Christopher Li
2007-02-26 19:57 ` Josh Triplett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).