From 4c90a7a218cf425af452b206451dd89f34b991cf Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 20 Mar 2009 15:48:35 +0000 Subject: [PATCH] avoid buffer overrun when there are more than 128 path entries * lcr_ifact.c (PATH_LIST_SIZE): Define. (path_list): Use it. (ld_library_path_build): Don't store into path_list[path_list_entries] if the counter is too large. (ldso_path_build): Likewise. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1883 fd59a12c-fef9-0310-b244-a6a79926bd2f --- lcr/lcr_ifact.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lcr/lcr_ifact.c b/lcr/lcr_ifact.c index caaa280b..c447a672 100644 --- a/lcr/lcr_ifact.c +++ b/lcr/lcr_ifact.c @@ -167,7 +167,8 @@ static inline int lcr_lib_loaded ( return (0); } -const char *path_list[128]; +enum { PATH_LIST_SIZE = 128 }; +const char *path_list[PATH_LIST_SIZE]; unsigned int path_list_entries = 0; static void defaults_path_build (void) @@ -201,7 +202,7 @@ static void ld_library_path_build (void) p_s = strtok_r (my_ld_library_path, ":", &ptrptr); while (p_s != NULL) { char *p = strdup (p_s); - if (p) { + if (p && path_list_entries < PATH_LIST_SIZE) { path_list[path_list_entries++] = p; } p_s = strtok_r (NULL, ":", &ptrptr); @@ -266,7 +267,7 @@ static int ldso_path_build (const char *path, const char *filename) continue; } p = strdup (string); - if (p) { + if (p && path_list_entries < PATH_LIST_SIZE) { path_list[path_list_entries++] = p; } }