1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-24 04:33:24 +00:00

Use random() because rand() is just too lame

Fix a potential buffer overflow I noticed while in here
Bump PORTREVISION
This commit is contained in:
Kris Kennaway 2001-03-03 00:45:13 +00:00
parent fd5612a029
commit d41accf670
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=39000
4 changed files with 79 additions and 1 deletions

View File

@ -7,7 +7,7 @@
PORTNAME= aalib
PORTVERSION= 1.2
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= graphics
MASTER_SITES= ftp://horac.ta.jcu.cz/pub/aa/ \
${MASTER_SITE_SUNSITE}

View File

@ -0,0 +1,39 @@
--- aafire.c.orig Fri Mar 2 16:30:27 2001
+++ aafire.c Fri Mar 2 16:31:17 2001
@@ -51,6 +51,7 @@
static void initialize()
{
int i;
+ srandomdev();
context = aa_autoinit(&aa_defparams);
if (context == NULL) {
printf("Failed to initialize aalib\n");
@@ -107,21 +108,21 @@
height++;
loop--;
if (loop < 0)
- loop = rand() % 3, sloop++;;
+ loop = random() % 3, sloop++;;
i1 = 1;
i2 = 4 * XSIZ + 1;
for (p = (char *) bitmap + XSIZ * (YSIZ + 0); p < ((unsigned char *) bitmap + XSIZ * (YSIZ + 1)); p++, i1 += 4, i2 -= 4) {
- last1 = rand() % min(i1, min(i2, height));
- i = rand() % 6;
+ last1 = random() % min(i1, min(i2, height));
+ i = random() % 6;
for (; p < (unsigned char *) bitmap + XSIZ * (YSIZ + 1) && i != 0; p++, i--, i1 += 4, i2 -= 4)
- *p = last1, last1 += rand() % 6 - 2,
- *(p + XSIZ) = last1, last1 += rand() % 6 - 2;
- *(p + 2 * XSIZ) = last1, last1 += rand() % 6 - 2;
+ *p = last1, last1 += random() % 6 - 2,
+ *(p + XSIZ) = last1, last1 += random() % 6 - 2;
+ *(p + 2 * XSIZ) = last1, last1 += random() % 6 - 2;
}
/*
for(p=bitmap+XSIZ*YSIZ;p<bitmap+(YSIZ+2)*XSIZ;p++)
{
- *p=rand();
+ *p=random();
} */
i = 0;
firemain();

View File

@ -0,0 +1,28 @@
--- aarender.c.orig Mon Oct 13 10:21:01 1997
+++ aarender.c Fri Mar 2 16:30:17 2001
@@ -26,11 +26,11 @@
return (p);
}
#define MYLONG_MAX 0xffffffff /*this is enought for me. */
-#define myrand() (state = ((state * 1103515245) + 12345) & MYLONG_MAX)
+#define myrand() (random() & MYLONG_MAX)
void aa_renderpalette(aa_context * c, aa_palette palette, aa_renderparams * p, int x1, int y1, int x2, int y2)
{
- static int state;
+ static int rand_init = 0;
int x, y;
int val;
int wi = c->imgwidth;
@@ -43,6 +43,11 @@
int mval;
int gamma = p->gamma != 1.0;
aa_palette table;
+
+ if (!rand_init) {
+ srandomdev();
+ rand_init = 1;
+ }
if (x2 < 0 || y2 < 0 || x1 > aa_scrwidth(c) || y1 > aa_scrheight(c))
return;
if (x2 >= aa_scrwidth(c))

View File

@ -0,0 +1,11 @@
--- aaprintf.c.orig Fri Mar 2 16:34:22 2001
+++ aaprintf.c Fri Mar 2 16:35:20 2001
@@ -6,7 +6,7 @@
char buf[1025];
int i;
va_start(args,fmt);
- i=vsprintf(buf,fmt,args);
+ i=vsnprintf(buf,sizeof(buf),fmt,args);
va_end(args);
aa_puts(c,x,y,attr,buf);
return i;