tags 355887 patch thanks On Thu, Mar 09, 2006 at 12:08:07AM -0800, Steve Langasek wrote: > On Thu, Mar 09, 2006 at 07:05:00AM +0100, Malte Schirmacher wrote: > > > Well trying to install it the same error occurs like in the other report: > > Ok, well, the strace you forwarded clearly didn't come from an instance in > which typespeed segfaulted.
Hi, I believe I have found the cause of the segfault. It happens when $HOME is not set. The readconfig() function in files.c uses getenv("HOME") without checking if it's NULL. The HOME environment variable may have been unset for the bug reporter because of the recent sudo issues. With sudo 1.6.8p7-1.3, which was the current version at the time this bug was reported, HOME indeed becomes unset. Then 'typespeed --makescores' segfaults in the postinst when using % sudo apt-get install typespeed I'm attaching a trivial patch that fixes this. It skips reading the user-specific configuration file if $HOME is not set. Cheers, -- Niko Tyni [EMAIL PROTECTED]
--- typespeed-0.4.4/file.c 2006-04-24 22:11:55.306574278 +0300 +++ typespeed-0.4.4-fixed/file.c 2006-04-24 22:11:37.624605957 +0300 @@ -512,10 +512,6 @@ char tmp[10]; char *userhome; - userhome = malloc((2+strlen(getenv("HOME"))+strlen(LOCALCONF))*sizeof(char)); - strcpy(userhome,getenv("HOME")); - strcat(userhome,"/"); - strcat(userhome,LOCALCONF); hakemisto = malloc(1026 * sizeof(char)); getcwd(hakemisto, 1024); conffile = fopen(CONFIGFILE, "r"); @@ -528,6 +524,13 @@ fclose(conffile); chdir(wordhakemisto); } + if (getenv("HOME") == NULL) { + return; + } + userhome = malloc((2+strlen(getenv("HOME"))+strlen(LOCALCONF))*sizeof(char)); + strcpy(userhome,getenv("HOME")); + strcat(userhome,"/"); + strcat(userhome,LOCALCONF); conffile = fopen(userhome, "r"); if (conffile != NULL) { fgets(wordhakemisto,1024,conffile);