--- src/conky.h.old 2005-11-30 01:08:25.000000000 -0500 +++ src/conky.h 2005-11-29 12:35:21.000000000 -0500 @@ -3,7 +3,7 @@ * * This program is licensed under BSD license, read COPYING * - * $Id: conky-1.3.4-arraybounds.patch,v 1.1 2005/12/11 03:36:33 dragonheart Exp $ + * $Id: conky-1.3.4-arraybounds.patch,v 1.1 2005/12/11 03:36:33 dragonheart Exp $ */ #ifndef _conky_h_ @@ -55,6 +55,9 @@ #define CRIT_ERR(s, varargs...) \ { fprintf(stderr, "Conky: " s "\n", ##varargs); exit(EXIT_FAILURE); } +#define MIN(a,b) (a>b ? b : a) +#define MAX(a,b) (a TEXT_BUFFER_SIZE-1 ) + fprintf(stderr,"buffer overrun detected\n"); + */ + tmpstring2[ MIN(pos + i2, TEXT_BUFFER_SIZE-1) ] = ' '; /* guard against overrun */ added++; } pos += i2; } else { if (tmpstring1[i] != 9) { - tmpstring2[pos] = tmpstring1[i]; + /* + if ( pos > TEXT_BUFFER_SIZE-1 ) + fprintf(stderr,"buffer overrun detected\n"); + */ + tmpstring2[ MIN(pos, TEXT_BUFFER_SIZE-1) ] = tmpstring1[i]; /* guard against overrun */ pos++; } }