mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-05 21:07:52 +00:00
added tmpstring overrun guards
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@434 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
80b9e6c9eb
commit
cca4732102
16
src/conky.c
16
src/conky.c
@ -3462,7 +3462,9 @@ static void draw_string(const char *s)
|
|||||||
printf("%s\n", s);
|
printf("%s\n", s);
|
||||||
}
|
}
|
||||||
/* daemon_run(s); the daemon can be called here, but we need to have a buffer in daemon_run() and we need to tell it when everything is ready to be sent */
|
/* daemon_run(s); the daemon can be called here, but we need to have a buffer in daemon_run() and we need to tell it when everything is ready to be sent */
|
||||||
strcpy(tmpstring1, s);
|
memset(tmpstring1,0,TEXT_BUFFER_SIZE);
|
||||||
|
memset(tmpstring2,0,TEXT_BUFFER_SIZE);
|
||||||
|
strncpy(tmpstring1, s, TEXT_BUFFER_SIZE-1);
|
||||||
pos = 0;
|
pos = 0;
|
||||||
added = 0;
|
added = 0;
|
||||||
char space[2];
|
char space[2];
|
||||||
@ -3483,13 +3485,21 @@ static void draw_string(const char *s)
|
|||||||
for (i2 = 0;
|
for (i2 = 0;
|
||||||
i2 < (8 - (1 + pos) % 8) && added <= max;
|
i2 < (8 - (1 + pos) % 8) && added <= max;
|
||||||
i2++) {
|
i2++) {
|
||||||
tmpstring2[pos + i2] = ' ';
|
/*
|
||||||
|
if ( pos + i2 > TEXT_BUFFER_SIZE-1 )
|
||||||
|
fprintf(stderr,"buffer overrun detected\n");
|
||||||
|
*/
|
||||||
|
tmpstring2[ MIN(pos + i2, TEXT_BUFFER_SIZE-1) ] = ' '; /* guard against overrun */
|
||||||
added++;
|
added++;
|
||||||
}
|
}
|
||||||
pos += i2;
|
pos += i2;
|
||||||
} else {
|
} else {
|
||||||
if (tmpstring1[i] != 9) {
|
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++;
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,9 @@ fprintf(stderr, "Conky: " s "\n", ##varargs)
|
|||||||
#define CRIT_ERR(s, varargs...) \
|
#define CRIT_ERR(s, varargs...) \
|
||||||
{ fprintf(stderr, "Conky: " s "\n", ##varargs); exit(EXIT_FAILURE); }
|
{ fprintf(stderr, "Conky: " s "\n", ##varargs); exit(EXIT_FAILURE); }
|
||||||
|
|
||||||
|
#define MIN(a,b) (a>b ? b : a)
|
||||||
|
#define MAX(a,b) (a<b ? b : a)
|
||||||
|
|
||||||
struct i8k_struct {
|
struct i8k_struct {
|
||||||
char *version;
|
char *version;
|
||||||
char *bios;
|
char *bios;
|
||||||
|
Loading…
Reference in New Issue
Block a user