merged thanks! -steve
On Thu, 2009-03-19 at 15:09 +0100, Jim Meyering wrote: > This is 3/3, but reworked not to require stmt-after-decl support, > plus another to fix a bug that would arise when parsing more than 128 paths. > > From 412490b7f05d5496b73ecb935c9faeb0ce5c36aa Mon Sep 17 00:00:00 2001 > From: Jim Meyering <[email protected]> > Date: Thu, 19 Mar 2009 14:53:59 +0100 > Subject: [PATCH 1/2] don't store (and later dereference NULL) upon strdup > failure > > (ldso_path_build): Don't store NULL when strdup fails. > --- > lcr/lcr_ifact.c | 5 ++++- > 1 files changed, 4 insertions(+), 1 deletions(-) > > diff --git a/lcr/lcr_ifact.c b/lcr/lcr_ifact.c > index 4548b96..f40fab4 100644 > --- a/lcr/lcr_ifact.c > +++ b/lcr/lcr_ifact.c > @@ -245,6 +245,7 @@ static int ldso_path_build (const char *path, const char > *filename) > } > > while (fgets (string, sizeof (string), fp)) { > + char *p; > if (strlen(string) > 0) > string[strlen(string) - 1] = '\0'; > if (strncmp (string, "include", strlen ("include")) == 0) { > @@ -263,7 +264,9 @@ static int ldso_path_build (const char *path, const char > *filename) > ldso_path_build (newpath, new_filename); > continue; > } > - path_list[path_list_entries++] = strdup (string); > + p = strdup (string); > + if (p) > + path_list[path_list_entries++] = p; > } > fclose(fp); > #endif > -- > 1.6.2.rc1.285.gc5f54 > > > From facba002e42ea85e6a5be5c2cb9cc38be78716aa Mon Sep 17 00:00:00 2001 > From: Jim Meyering <[email protected]> > Date: Thu, 19 Mar 2009 15:08:03 +0100 > Subject: [PATCH 2/2] avoid buffer overrun when there are more than 128 path > entries > > * lcr_ifact.c (ld_library_path_build, ldso_path_build): Don't store > into path_list[path_list_entries] if the counter is too large. > --- > lcr/lcr_ifact.c | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/lcr/lcr_ifact.c b/lcr/lcr_ifact.c > index f40fab4..d8e8a4d 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); > } > @@ -265,7 +266,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; > } > fclose(fp); > -- > 1.6.2.rc1.285.gc5f54 > _______________________________________________ > Openais mailing list > [email protected] > https://lists.linux-foundation.org/mailman/listinfo/openais _______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
