mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-03 20:48:31 +00:00
Bugfix: gw_iface with a empty routingtable no longer causes a crash
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1124 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
8f8d5c1c8c
commit
07269f678d
3
AUTHORS
3
AUTHORS
@ -62,6 +62,9 @@ Dave Clark <clarkd at skynet dot ca>
|
|||||||
David McCabe
|
David McCabe
|
||||||
utime
|
utime
|
||||||
|
|
||||||
|
garo <nikolas at garofil dot be>
|
||||||
|
gw_iface fix
|
||||||
|
|
||||||
Ram Yalamanchili
|
Ram Yalamanchili
|
||||||
tztime
|
tztime
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
2008-06-04
|
||||||
|
* Fix bug where conky tries to free a already freed pointer when you
|
||||||
|
use gw_iface with a empty routingtable in linux
|
||||||
|
|
||||||
2008-06-03
|
2008-06-03
|
||||||
* Added NVIDIA Graficcard support patch (thanks meissna)
|
* Added NVIDIA Graficcard support patch (thanks meissna)
|
||||||
* Added --quiet patch (thanks sceptik)
|
* Added --quiet patch (thanks sceptik)
|
||||||
|
22
src/linux.c
22
src/linux.c
@ -261,6 +261,16 @@ END_TRUE:
|
|||||||
x = strndup(y, text_buffer_size); \
|
x = strndup(y, text_buffer_size); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void update_gateway_info_failure(char *reason)
|
||||||
|
{
|
||||||
|
if(reason != NULL) {
|
||||||
|
perror(reason);
|
||||||
|
}
|
||||||
|
//2 pointers to 1 location causes a crash when we try to free them both
|
||||||
|
info.gw_info.iface = strndup("failed", text_buffer_size);
|
||||||
|
info.gw_info.ip = strndup("failed", text_buffer_size);
|
||||||
|
}
|
||||||
|
|
||||||
void update_gateway_info(void)
|
void update_gateway_info(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -277,14 +287,13 @@ void update_gateway_info(void)
|
|||||||
gw_info->count = 0;
|
gw_info->count = 0;
|
||||||
|
|
||||||
if ((fp = fopen("/proc/net/route", "r")) == NULL) {
|
if ((fp = fopen("/proc/net/route", "r")) == NULL) {
|
||||||
perror("fopen()");
|
update_gateway_info_failure("fopen()");
|
||||||
info.gw_info.iface = info.gw_info.ip = strndup("failed", text_buffer_size);
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (fscanf(fp, "%*[^\n]\n") == EOF) {
|
if (fscanf(fp, "%*[^\n]\n") == EOF) {
|
||||||
perror("fscanf()");
|
//NULL because a empty table is not a error
|
||||||
|
update_gateway_info_failure(NULL);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
info.gw_info.iface = info.gw_info.ip = strndup("failed", text_buffer_size);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (!feof(fp)) {
|
while (!feof(fp)) {
|
||||||
@ -292,9 +301,8 @@ void update_gateway_info(void)
|
|||||||
if(fscanf(fp, "%63s %lx %lx %x %hd %hd %hd %lx %hd %hd %hd\n",
|
if(fscanf(fp, "%63s %lx %lx %x %hd %hd %hd %lx %hd %hd %hd\n",
|
||||||
iface, &dest, &gate, &flags, &ref, &use,
|
iface, &dest, &gate, &flags, &ref, &use,
|
||||||
&metric, &mask, &mtu, &win, &irtt) != 11) {
|
&metric, &mask, &mtu, &win, &irtt) != 11) {
|
||||||
perror("fscanf()");
|
update_gateway_info_failure("fscanf()");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
info.gw_info.iface = info.gw_info.ip = strndup("failed", text_buffer_size);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (flags & RTF_GATEWAY && dest == 0 && mask == 0) {
|
if (flags & RTF_GATEWAY && dest == 0 && mask == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user