From f02db3217ea416cabafe2d65e4d03ed372c3bf0c Mon Sep 17 00:00:00 2001 From: Alexander Bersenev Date: Tue, 31 Jan 2012 18:30:20 +0600 Subject: fixed crashes in ruby's rb_thread_blocking_region(). Shrink buffer for proc entrys --- src/hook_lib/file_hook.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hook_lib/file_hook.c b/src/hook_lib/file_hook.c index 728ab4e..cd3850a 100644 --- a/src/hook_lib/file_hook.c +++ b/src/hook_lib/file_hook.c @@ -22,6 +22,7 @@ #include #define MAXPATHLEN PATH_MAX +#define MAXPROCPATHLEN 512 #define MAXSOCKETPATHLEN 108 #define MAXFILEBUFFLEN 2048 @@ -292,9 +293,9 @@ static char * __get_stage(){ * Get full path by fd */ ssize_t __get_path_by_fd(int fd, char *output, int output_len) { - char path_to_fd_link[MAXPATHLEN]; + char path_to_fd_link[MAXPROCPATHLEN]; - snprintf(path_to_fd_link,MAXPATHLEN,"/proc/self/fd/%d",fd); + snprintf(path_to_fd_link,MAXPROCPATHLEN,"/proc/self/fd/%d",fd); ssize_t bytes_num=readlink(path_to_fd_link,output,output_len-1); output[bytes_num]=0; // because readlink don't do this if(output[0]!='/') return -1; // some odd string like pipe: -- cgit v1.2.3