1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-27 09:08:25 +00:00

Fix inotify segfault (sf.net #2804886).

Fix segfault due to bad checking of return values for inotify code
(sf.net #2804886)
This commit is contained in:
Brenden Matthews 2009-06-13 13:17:18 -06:00
parent 1933df5f31
commit ca340d2643
3 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,7 @@
2009-06-13 2009-06-13
* Added support for $to_bytes * Added support for $to_bytes
* Fix segfault due to bad checking of return values for inotify code
(sf.net #2804886)
2009-06-12 2009-06-12
* Added support for per-task I/O statistics - $top_io * Added support for per-task I/O statistics - $top_io

View File

@ -6851,7 +6851,7 @@ static void main_loop(void)
#endif #endif
double t; double t;
#ifdef HAVE_SYS_INOTIFY_H #ifdef HAVE_SYS_INOTIFY_H
int inotify_config_wd = 0; int inotify_config_wd = -1;
#define INOTIFY_EVENT_SIZE (sizeof(struct inotify_event)) #define INOTIFY_EVENT_SIZE (sizeof(struct inotify_event))
#define INOTIFY_BUF_LEN (20 * (INOTIFY_EVENT_SIZE + 16)) #define INOTIFY_BUF_LEN (20 * (INOTIFY_EVENT_SIZE + 16))
char inotify_buff[INOTIFY_BUF_LEN]; char inotify_buff[INOTIFY_BUF_LEN];
@ -7184,12 +7184,12 @@ static void main_loop(void)
break; break;
} }
#ifdef HAVE_SYS_INOTIFY_H #ifdef HAVE_SYS_INOTIFY_H
if (inotify_fd && !inotify_config_wd) { if (inotify_fd != -1 && inotify_config_wd != -1) {
inotify_config_wd = inotify_add_watch(inotify_fd, inotify_config_wd = inotify_add_watch(inotify_fd,
current_config, current_config,
IN_MODIFY); IN_MODIFY);
} }
if (inotify_fd && inotify_config_wd) { if (inotify_fd != -1 && inotify_config_wd != -1) {
int len = 0, idx = 0; int len = 0, idx = 0;
fd_set descriptors; fd_set descriptors;
struct timeval time_to_wait; struct timeval time_to_wait;
@ -7232,7 +7232,7 @@ static void main_loop(void)
} }
#ifdef HAVE_SYS_INOTIFY_H #ifdef HAVE_SYS_INOTIFY_H
if (inotify_fd) { if (inotify_fd != -1) {
inotify_rm_watch(inotify_fd, inotify_config_wd); inotify_rm_watch(inotify_fd, inotify_config_wd);
close(inotify_fd); close(inotify_fd);
inotify_fd = inotify_config_wd = 0; inotify_fd = inotify_config_wd = 0;

View File

@ -52,7 +52,7 @@ void llua_load(const char *script)
ERR("llua_load: %s", lua_tostring(lua_L, -1)); ERR("llua_load: %s", lua_tostring(lua_L, -1));
lua_pop(lua_L, 1); lua_pop(lua_L, 1);
#ifdef HAVE_SYS_INOTIFY_H #ifdef HAVE_SYS_INOTIFY_H
} else if (!llua_block_notify && inotify_fd) { } else if (!llua_block_notify && inotify_fd != -1) {
llua_append_notify(script); llua_append_notify(script);
#endif /* HAVE_SYS_INOTIFY_H */ #endif /* HAVE_SYS_INOTIFY_H */
} }