1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
Description: fix mtinkc crash when run with an empty environment
Running 'env -i /usr/bin/mtinkc' results in a segfault.
This patch avoids operations on NULL string pointers and
delays calling mtink until topLevel has been created.
Bug-Debian: http://bugs.debian.org/716125
Author: Graham Inggs <graham@nerve.org.za>
Forwarded: No, nothing left to forward to
Last-Update: 2013-07-31
--- a/chooser/mtinkc.c
+++ b/chooser/mtinkc.c
@@ -193,6 +193,10 @@
DIR *dir;
struct dirent *ent;
+ if ( home == NULL )
+ {
+ return 0;
+ }
fileName = (char*)calloc(strlen(home)+100,1);
*nodes = (nodes_t*)calloc(sizeof(nodes_t),1);
@@ -619,14 +623,6 @@
/* look for the display name if given */
getDisplayName(argc, argv);
- /* only 0 entry is the rc file, we have not to offer choices */
- /* call mtink now */
- if ( n == 0 )
- {
- callCommand(n,topLevel);
- exit(0);
- }
-
/* make the topLevel */
mainResource = (char*)calloc(strlen(prgName)+3,1);
strcpy(mainResource,prgName);
@@ -647,6 +643,14 @@
fprintf(stderr,"%s: can't connect to X11\n", prgName);
exit(1);
}
+
+ /* only 0 entry is the rc file, we have not to offer choices */
+ /* call mtink now */
+ if ( n == 0 )
+ {
+ callCommand(n,topLevel);
+ exit(0);
+ }
/* don't map now */
XtVaSetValues(topLevel, XmNmappedWhenManaged, False, NULL);
|