Mesa (mesa_7_7_branch): progs/demos: Bounds check input to fire.c.
Vinson Lee
vlee at kemper.freedesktop.org
Sun Jan 10 08:41:32 UTC 2010
Module: Mesa
Branch: mesa_7_7_branch
Commit: 0c7814fe238fe0e2bbeff448c32f79146f9ae923
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c7814fe238fe0e2bbeff448c32f79146f9ae923
Author: Vinson Lee <vlee at vmware.com>
Date: Sun Jan 10 00:40:46 2010 -0800
progs/demos: Bounds check input to fire.c.
---
progs/demos/fire.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/progs/demos/fire.c b/progs/demos/fire.c
index f30b893..475582c 100644
--- a/progs/demos/fire.c
+++ b/progs/demos/fire.c
@@ -726,8 +726,13 @@ main(int ac, char **av)
maxage = 1.0 / dt;
- if (ac == 2)
+ if (ac == 2) {
np = atoi(av[1]);
+ if (np <= 0 || np > 1000000) {
+ fprintf(stderr, "Invalid input.\n");
+ exit(-1);
+ }
+ }
if (ac == 4) {
WIDTH = atoi(av[2]);
@@ -762,6 +767,7 @@ main(int ac, char **av)
assert(np > 0);
p = (part *) malloc(sizeof(part) * np);
+ assert(p);
for (i = 0; i < np; i++)
setnewpart(&p[i]);
More information about the mesa-commit
mailing list