diff options
author | dholland <dholland@pkgsrc.org> | 2012-12-27 00:23:21 +0000 |
---|---|---|
committer | dholland <dholland@pkgsrc.org> | 2012-12-27 00:23:21 +0000 |
commit | 663699aeeeffbf8eaa614bc6493ad94a7e49997c (patch) | |
tree | cb8420900fccfe2d5fd4ca815f00567a100705f6 | |
parent | 3243c73c3236b5f26371d340af59f4288e77d128 (diff) | |
download | pkgsrc-663699aeeeffbf8eaa614bc6493ad94a7e49997c.tar.gz |
Pass around input buffer lengths properly and don't use gets().
PKGREVISION -> 11 for this and previous changes.
-rw-r--r-- | graphics/radiance/Makefile | 4 | ||||
-rw-r--r-- | graphics/radiance/distinfo | 12 | ||||
-rw-r--r-- | graphics/radiance/patches/patch-src_rt_devcomm.c | 57 | ||||
-rw-r--r-- | graphics/radiance/patches/patch-src_rt_driver.h | 27 | ||||
-rw-r--r-- | graphics/radiance/patches/patch-src_rt_editline.c | 59 | ||||
-rw-r--r-- | graphics/radiance/patches/patch-src_rt_rv2.c | 150 | ||||
-rw-r--r-- | graphics/radiance/patches/patch-src_rt_rview.c | 15 | ||||
-rw-r--r-- | graphics/radiance/patches/patch-src_rt_tty.c | 22 | ||||
-rw-r--r-- | graphics/radiance/patches/patch-src_rt_vga.c | 23 | ||||
-rw-r--r-- | graphics/radiance/patches/patch-src_rt_x11.c | 61 |
10 files changed, 426 insertions, 4 deletions
diff --git a/graphics/radiance/Makefile b/graphics/radiance/Makefile index ef7990a0562..75e6b06932c 100644 --- a/graphics/radiance/Makefile +++ b/graphics/radiance/Makefile @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.33 2012/10/06 14:11:19 asau Exp $ +# $NetBSD: Makefile,v 1.34 2012/12/27 00:23:21 dholland Exp $ # DISTNAME= rad3R6P1 PKGNAME= radiance-3.6.1 -PKGREVISION= 10 +PKGREVISION= 11 CATEGORIES= graphics MASTER_SITES= http://www.radiance-online.org/software/non-cvs/ \ http://www.radiance-online.org/software/ diff --git a/graphics/radiance/distinfo b/graphics/radiance/distinfo index 2bd50fd73d0..2550e0f0cb1 100644 --- a/graphics/radiance/distinfo +++ b/graphics/radiance/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.15 2012/12/27 00:20:56 dholland Exp $ +$NetBSD: distinfo,v 1.16 2012/12/27 00:23:21 dholland Exp $ SHA1 (rad3R6P1.tar.gz) = 71f46abd1c30be282a93237fa0c162d3bf0b1f99 RMD160 (rad3R6P1.tar.gz) = 3bcf40518a57cdb5455264c83a3e206b67b3d1fa @@ -29,8 +29,16 @@ SHA1 (patch-at) = 34bf252c122727308ebaa47177afabbc888a4f6a SHA1 (patch-au) = 35660480163fb7444ebbdb1fee4ad1cebf866ef4 SHA1 (patch-av) = 0bfd2ec0fb16f3c106a285b49f1cf48a29274fbb SHA1 (patch-aw) = 6b57d85e4c4ef4a3501f4a0263ef8a47fbac8958 -SHA1 (patch-src_common_readmesh.c) = a186fdb5a3bde532ed3ea50c295a0a0aaa1a36c9 +SHA1 (patch-src_common_readmesh.c) = 1e5b2a0abd5f50c69ccccb5db28688e914c3cc0a SHA1 (patch-src_meta_plot.h) = b6959e2d349dc25abbde816f4b128a2fb0218200 SHA1 (patch-src_meta_xmeta.c) = 360c282bd9adf376ea86140d6c63af523114618d SHA1 (patch-src_ot_writemesh.c) = 109266d289720ed6760f430ab7a7637312ac9c3d SHA1 (patch-src_ot_writeoct.c) = b6f6426ef6abf731cd5c9735e6012c07f5e9ff35 +SHA1 (patch-src_rt_devcomm.c) = c333b185e0bbe2755caf23ab57b8541502741320 +SHA1 (patch-src_rt_driver.h) = b6d9d921e6e702c0b16396e4613468d2f3f4664f +SHA1 (patch-src_rt_editline.c) = 1204617ad7ba397a02e1d9e8643aac4987bc713d +SHA1 (patch-src_rt_rv2.c) = 928fa2c53a563313e5b67936141f5e9d10d43bc1 +SHA1 (patch-src_rt_rview.c) = 6883f48bac08d2e66e60e83466cb9354a50f15c1 +SHA1 (patch-src_rt_tty.c) = 2155d7e9b3eb4aec8fca8eda5c606a920700dded +SHA1 (patch-src_rt_vga.c) = 80b3d9cc1e1c166efd9d8775454d4ddf0e8795f2 +SHA1 (patch-src_rt_x11.c) = ba63628c91bf6fa2ddb936efac36bc05cbd649a5 diff --git a/graphics/radiance/patches/patch-src_rt_devcomm.c b/graphics/radiance/patches/patch-src_rt_devcomm.c new file mode 100644 index 00000000000..b0ae7bfdb1f --- /dev/null +++ b/graphics/radiance/patches/patch-src_rt_devcomm.c @@ -0,0 +1,57 @@ +$NetBSD: patch-src_rt_devcomm.c,v 1.1 2012/12/27 00:23:21 dholland Exp $ + +Pass around input buffer lengths. + +--- src/rt/devcomm.c~ 2004-10-01 07:43:05.000000000 +0000 ++++ src/rt/devcomm.c +@@ -24,7 +24,7 @@ FILE *devin, *devout; + int devchild; + + static struct driver * final_connect(void); +-static void mygets(char *s, FILE *fp); ++static void mygets(char *s, size_t, FILE *fp); + static void myputs(char *s, FILE *fp); + static void reply_error(char *routine); + static void getstate(void); +@@ -223,6 +223,7 @@ comm_comout( /* print string to comman + static void + comm_comin( /* read string from command line */ + char *buf, ++ size_t max, + char *prompt + ) + { +@@ -236,7 +237,7 @@ comm_comin( /* read string from comman + fflush(devout); + if (getc(devin) != COM_COMIN) + reply_error("comin"); +- mygets(buf, devin); ++ mygets(buf, max, devin); + getstate(); + } + +@@ -244,15 +245,20 @@ comm_comin( /* read string from comman + static void + mygets( /* get string from file (with nul) */ + register char *s, +- register FILE *fp ++ size_t max, ++ FILE *fp + ) + { + register int c; ++ size_t pos = 0; + +- while ((c = getc(fp)) != EOF) +- if ((*s++ = c) == '\0') ++ while ((c = getc(fp)) != EOF) { ++ if (pos >= max - 1) ++ break; ++ if ((s[pos++] = c) == '\0') + return; ++ } +- *s = '\0'; ++ s[pos] = '\0'; + } + + diff --git a/graphics/radiance/patches/patch-src_rt_driver.h b/graphics/radiance/patches/patch-src_rt_driver.h new file mode 100644 index 00000000000..2d9d4bbd585 --- /dev/null +++ b/graphics/radiance/patches/patch-src_rt_driver.h @@ -0,0 +1,27 @@ +$NetBSD: patch-src_rt_driver.h,v 1.1 2012/12/27 00:23:21 dholland Exp $ + +Pass around input buffer lengths. + +--- src/rt/driver.h~ 2004-04-10 02:54:09.000000000 +0000 ++++ src/rt/driver.h +@@ -20,7 +20,7 @@ typedef void dr_clearf_t(int, int); + typedef void dr_paintrf_t(COLOR col, int xmin, int ymin, int xmax, int ymax); + typedef int dr_getcurf_t(int*,int*); + typedef void dr_comoutf_t(char*); +-typedef void dr_cominf_t(char*,char*); ++typedef void dr_cominf_t(char*,size_t,char*); + typedef void dr_flushf_t(void); + + struct driver { /* driver functions */ +@@ -212,9 +212,9 @@ extern char dev_default[]; /* default + */ + + /* defined in editline.c */ +-extern void editline(char *buf, dr_getchf_t *c_get, dr_comoutf_t *s_put); ++extern void editline(char *buf, size_t max, dr_getchf_t *c_get, dr_comoutf_t *s_put); + extern void tocombuf(char *b, struct driver *d); +-extern int fromcombuf(char *b, struct driver *d); ++extern int fromcombuf(char *b, size_t max, struct driver *d); + + /* defined in devcomm.c */ + extern dr_initf_t slave_init; /* XXX should probably be in a seperate file */ diff --git a/graphics/radiance/patches/patch-src_rt_editline.c b/graphics/radiance/patches/patch-src_rt_editline.c new file mode 100644 index 00000000000..81e79d2a672 --- /dev/null +++ b/graphics/radiance/patches/patch-src_rt_editline.c @@ -0,0 +1,59 @@ +$NetBSD: patch-src_rt_editline.c,v 1.1 2012/12/27 00:23:21 dholland Exp $ + +Pass around (and honor) input buffer lengths. + +--- src/rt/editline.c~ 2004-04-10 02:54:09.000000000 +0000 ++++ src/rt/editline.c +@@ -26,13 +26,14 @@ static const char RCSid[] = "$Id: editli + extern void + editline( /* edit input line */ + char *buf, ++ size_t bufmax, + dr_getchf_t *c_get, + dr_comoutf_t *s_put + ) + { + static char erases[] = "\b \b"; + static char obuf[4]; +- register int i; ++ register size_t i; + register int c; + + i = 0; +@@ -62,6 +63,8 @@ editline( /* edit input line */ + obuf[0] = '^'; obuf[1] = c|0100; obuf[2] = '\0'; + (*s_put)(obuf); + break; ++ } else if (i >= bufmax - 1) { /* overflow */ ++ (*s_put)("\a"); + } else { /* regular char */ + buf[i++] = c; + obuf[0] = c; obuf[1] = '\0'; +@@ -98,16 +101,22 @@ register struct driver *d; + + + int +-fromcombuf(b, d) /* get command from my buffer */ ++fromcombuf(b, max, d) /* get command from my buffer */ + char *b; ++size_t max; + struct driver *d; + { +- register char *cp; ++ char *cp; ++ size_t pos; + /* get next command */ +- for (cp = mybuf; *cp != '\n'; cp++) +- if (!*cp) ++ for (pos = 0; mybuf[pos] != '\n' && pos < max - 1; pos++) ++ if (!mybuf[pos]) + return(0); +- *cp++ = '\0'; ++ /* ++ * On overflow this loses a character, but it isn't supposed ++ * to overflow. ++ */ ++ mybuf[pos++] = '\0'; + #ifdef DEBUG + (*d->comout)(mybuf); /* echo my command */ + (*d->comout)("\n"); diff --git a/graphics/radiance/patches/patch-src_rt_rv2.c b/graphics/radiance/patches/patch-src_rt_rv2.c new file mode 100644 index 00000000000..5756c65d9c5 --- /dev/null +++ b/graphics/radiance/patches/patch-src_rt_rv2.c @@ -0,0 +1,150 @@ +$NetBSD: patch-src_rt_rv2.c,v 1.1 2012/12/27 00:23:21 dholland Exp $ + +Pass around input buffer lengths. + +--- src/rt/rv2.c~ 2004-04-10 02:54:10.000000000 +0000 ++++ src/rt/rv2.c +@@ -96,7 +96,7 @@ getview( /* get/show view parameters + } + sprintf(buf, "view type (%c): ", ourview.type); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (buf[0] == CTRL('C')) return; + if (buf[0] && buf[0] != ourview.type) { + nv.type = buf[0]; +@@ -106,7 +106,7 @@ getview( /* get/show view parameters + sprintf(buf, "view point (%.6g %.6g %.6g): ", + ourview.vp[0], ourview.vp[1], ourview.vp[2]); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (buf[0] == CTRL('C')) return; + if (sscanvec(buf, nv.vp)) + change++; +@@ -115,7 +115,7 @@ getview( /* get/show view parameters + sprintf(buf, "view direction (%.6g %.6g %.6g): ", + ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (buf[0] == CTRL('C')) return; + if (sscanvec(buf, nv.vdir)) + change++; +@@ -124,7 +124,7 @@ getview( /* get/show view parameters + sprintf(buf, "view up (%.6g %.6g %.6g): ", + ourview.vup[0], ourview.vup[1], ourview.vup[2]); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (buf[0] == CTRL('C')) return; + if (sscanvec(buf, nv.vup)) + change++; +@@ -133,7 +133,7 @@ getview( /* get/show view parameters + sprintf(buf, "view horiz and vert size (%.6g %.6g): ", + ourview.horiz, ourview.vert); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (buf[0] == CTRL('C')) return; + if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) + change++; +@@ -143,7 +143,7 @@ getview( /* get/show view parameters + sprintf(buf, "fore and aft clipping plane (%.6g %.6g): ", + ourview.vfore, ourview.vaft); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (buf[0] == CTRL('C')) return; + if (sscanf(buf, "%lf %lf", &nv.vfore, &nv.vaft) == 2) + change++; +@@ -153,7 +153,7 @@ getview( /* get/show view parameters + sprintf(buf, "view shift and lift (%.6g %.6g): ", + ourview.hoff, ourview.voff); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (buf[0] == CTRL('C')) return; + if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) + change++; +@@ -404,7 +404,7 @@ getexposure( /* get new exposure */ + if (*cp == '\0') { /* interactive */ + sprintf(buf, "exposure (%f): ", exposure); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + for (cp = buf; isspace(*cp); cp++) + ; + if (*cp == '\0') +@@ -454,7 +454,7 @@ getparam( /* get variable from user */ + (*dev->comout)(dsc); + sprintf(buf, " (%d): ", ptr->i); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (sscanf(buf, "%d", &i0) != 1) + return(0); + } +@@ -465,7 +465,7 @@ getparam( /* get variable from user */ + (*dev->comout)(dsc); + sprintf(buf, " (%.6g): ", ptr->d); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (sscanf(buf, "%lf", &d0) != 1) + return(0); + } +@@ -476,7 +476,7 @@ getparam( /* get variable from user */ + (*dev->comout)(dsc); + sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n'); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (buf[0] == '\0' || + strchr("yY+1tTnN-0fF", buf[0]) == NULL) + return(0); +@@ -491,7 +491,7 @@ getparam( /* get variable from user */ + colval(ptr->C,GRN), + colval(ptr->C,BLU)); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3) + return(0); + } +@@ -512,7 +512,7 @@ setparam( /* get/set program paramete + if (s[0] == '\0') { + (*dev->comout)( + "aa ab ad ar as av aw b dc dv dj ds dt i lr lw me ma mg ms ps pt sj st bv: "); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + s = buf; + } + switch (s[0]) { +@@ -725,7 +725,7 @@ char *s; + sprintf(buf+strlen(buf), " in %s \"%s\"", + ofun[ino->otype].funame, ino->oname); + (*dev->comout)(buf); +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + if (thisray.rot >= FHUGE) + (*dev->comout)("at infinity"); + else { +@@ -734,7 +734,7 @@ char *s; + thisray.rop[2], thisray.rt); + (*dev->comout)(buf); + } +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + sprintf(buf, "value (%.5g %.5g %.5g) (%.3gL)", + colval(thisray.rcol,RED), + colval(thisray.rcol,GRN), +@@ -742,7 +742,7 @@ char *s; + luminance(thisray.rcol)); + (*dev->comout)(buf); + } +- (*dev->comin)(buf, NULL); ++ (*dev->comin)(buf, sizeof(buf), NULL); + } + + diff --git a/graphics/radiance/patches/patch-src_rt_rview.c b/graphics/radiance/patches/patch-src_rt_rview.c new file mode 100644 index 00000000000..ec938c41d92 --- /dev/null +++ b/graphics/radiance/patches/patch-src_rt_rview.c @@ -0,0 +1,15 @@ +$NetBSD: patch-src_rt_rview.c,v 1.1 2012/12/27 00:23:21 dholland Exp $ + +Pass around input buffer lengths. + +--- src/rt/rview.c~ 2004-09-08 01:47:43.000000000 +0000 ++++ src/rt/rview.c +@@ -208,7 +208,7 @@ char *prompt; + char inpbuf[256]; + char *args; + again: +- (*dev->comin)(inpbuf, prompt); /* get command + arguments */ ++ (*dev->comin)(inpbuf, sizeof(inpbuf), prompt); /* get command + arguments */ + for (args = inpbuf; *args && *args != ' '; args++) + ; + if (*args) *args++ = '\0'; diff --git a/graphics/radiance/patches/patch-src_rt_tty.c b/graphics/radiance/patches/patch-src_rt_tty.c new file mode 100644 index 00000000000..4b027609b75 --- /dev/null +++ b/graphics/radiance/patches/patch-src_rt_tty.c @@ -0,0 +1,22 @@ +$NetBSD: patch-src_rt_tty.c,v 1.1 2012/12/27 00:23:21 dholland Exp $ + +Pass around input buffer lengths. + +--- src/rt/tty.c~ 2004-04-10 02:54:10.000000000 +0000 ++++ src/rt/tty.c +@@ -85,13 +85,14 @@ getch(void) /* get a character in ra + static void + ttyin( /* read a line in raw mode */ + char *buf, ++ size_t max, + char *prompt + ) + { + + if (prompt != NULL) + (*ttydev->comout)(prompt); +- editline(buf, getch, ttydev->comout); ++ editline(buf, max, getch, ttydev->comout); + } + + diff --git a/graphics/radiance/patches/patch-src_rt_vga.c b/graphics/radiance/patches/patch-src_rt_vga.c new file mode 100644 index 00000000000..cdfe6c5ed4f --- /dev/null +++ b/graphics/radiance/patches/patch-src_rt_vga.c @@ -0,0 +1,23 @@ +$NetBSD: patch-src_rt_vga.c,v 1.1 2012/12/27 00:23:21 dholland Exp $ + +Pass around input buffer lengths. + +--- src/rt/vga.c~ 2004-04-10 02:54:10.000000000 +0000 ++++ src/rt/vga.c +@@ -187,6 +187,7 @@ vga_errout( + static void + vga_comin( /* get input line from console */ + char *buf, ++ size_t max, + char *prompt + ) + { +@@ -194,7 +195,7 @@ vga_comin( /* get input line from cons + + if (prompt != NULL) + _outtext(prompt); +- editline(buf, getch, vga_comout); ++ editline(buf, max, getch, vga_comout); + vga_driver.inpready = kbhit(); + } + diff --git a/graphics/radiance/patches/patch-src_rt_x11.c b/graphics/radiance/patches/patch-src_rt_x11.c new file mode 100644 index 00000000000..c6287527944 --- /dev/null +++ b/graphics/radiance/patches/patch-src_rt_x11.c @@ -0,0 +1,61 @@ +$NetBSD: patch-src_rt_x11.c,v 1.1 2012/12/27 00:23:21 dholland Exp $ + +Pass around input buffer lengths. +Don't use gets(). + +--- src/rt/x11.c~ 2004-04-10 02:54:10.000000000 +0000 ++++ src/rt/x11.c +@@ -358,17 +358,18 @@ x11_flush(void) /* flush output */ + static void + x11_comin( /* read in a command line */ + char *inp, ++ size_t inpmax, + char *prompt + ) + { + if (prompt != NULL) { + x11_flush(); /* make sure we get everything */ +- if (fromcombuf(inp, &x11_driver)) ++ if (fromcombuf(inp, inpmax, &x11_driver)) + return; + xt_puts(prompt, comline); + } + xt_cursor(comline, TBLKCURS); +- editline(inp, x11_getc, x11_comout); ++ editline(inp, inpmax, x11_getc, x11_comout); + xt_cursor(comline, TNOCURS); + } + +@@ -399,11 +400,14 @@ x11_errout( /* output an error message + static void + std_comin( /* read in command line from stdin */ + char *inp, ++ size_t inpmax, + char *prompt + ) + { ++ size_t inplen; ++ + if (prompt != NULL) { +- if (fromcombuf(inp, &x11_driver)) ++ if (fromcombuf(inp, inpmax, &x11_driver)) + return; + if (!x11_driver.inpready) + std_comout(prompt); +@@ -417,11 +421,14 @@ std_comin( /* read in command line from + inpcheck = IC_IOCTL; + } + #endif +- if (gets(inp) == NULL) { ++ if (fgets(inp, inpmax, stdin) == NULL) { + strcpy(inp, "quit"); + return; + } +- x11_driver.inpready -= strlen(inp) + 1; ++ inplen = strlen(inp); ++ if (inplen > 0 && inp[inplen-1] == '\n') ++ inp[--inplen] = '\0'; ++ x11_driver.inpready -= inplen + 1; + if (x11_driver.inpready < 0) + x11_driver.inpready = 0; + } |