List Info

Thread: SIGSEGV in build_searchdirs()




SIGSEGV in build_searchdirs()
user name
2006-09-14 12:28:59
Hi Dave!

This patch fixes the following (minor) problem:

If the directory "/usr/src" does not exist and
crash is called without
parameters, it dies with SIGSEGV.

The reason is that the searchdirs buffer is not allocated,
if "/usr/src" is
not present. This fix allocates the buffer in any case.

---

 filesys.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff -Naur crash-4.0-3.3/filesys.c
crash-4.0-3.3-searchdirs-fix/filesys.c
--- crash-4.0-3.3/filesys.c	2006-09-07 21:00:08.000000000
+0200
+++ crash-4.0-3.3-searchdirs-fix/filesys.c	2006-09-14
14:02:35.000000000 +0200
 -315,14
+315,12 
                 for (dp = readdir(dirp); dp != NULL; dp =
readdir(dirp)) 
 			cnt++;
 
-		if ((searchdirs = (char **)malloc(cnt * sizeof(char *))) 
-		    == NULL) {
+		if ((searchdirs = calloc(cnt, sizeof(char *))) == NULL) {
 			error(INFO, "/usr/src/ directory list malloc:
%s\n",
                                 strerror(errno));
 			closedir(dirp);
 			return default_searchdirs;
 		} 
-		BZERO(searchdirs, cnt * sizeof(char *));
 
 		for (i = 0; i < DEFAULT_SEARCHDIRS; i++) 
 			searchdirs[i] = default_searchdirs[i];
 -357,6
+355,16 
 		closedir(dirp);
 
 		searchdirs[cnt] = NULL;
+	} else {
+		if ((searchdirs = calloc(cnt, sizeof(char *))) == NULL) {
+			error(INFO, "search directory list malloc:
%s\n",
+                                strerror(errno));
+			closedir(dirp);
+			return default_searchdirs;
+		} 
+		for (i = 0; i < DEFAULT_SEARCHDIRS; i++) 
+			searchdirs[i] = default_searchdirs[i];
+		cnt = DEFAULT_SEARCHDIRS;
 	}
 
         if (redhat_kernel_directory_v1(dirbuf)) {

--
Crash-utility mailing list
Crash-utilityredhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
Array
user name
1969-12-31 18:00:00
On Thursday 14 September 2006 10:43, Jean-Marc Lasgouttes
wrote:
> >>>>> "José" == José Matos
<jamatosfc.up.pt> writes:
>
> José> PS: Jean-Marc as you can see in the first
link, unicode supports
> José> composition , what you would expect from
unicodeaccent. 
>
> OK, so we could have an insetunicodecomposer or
whatever name. I think
> whatever is logically a single entity (character?)
should be seen by
> the kernel as one character.

  A grapheme, you mean. 
  Lars propose to deal with code points.

  In what case(s) do you expect the kernel needs to know
about graphemes and 
not code points?

  Are those cases relevant? I am not sure I am just asking.


> JMarc

-- 
José Abílio
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )