bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gettext] Bug in gettext


From: kosmak
Subject: [bug-gettext] Bug in gettext
Date: Fri, 17 Feb 2012 15:52:43 +0100
User-agent: LH Webmail/0.3.1

Hi, 
It's seems that in localealias.c there is a bug; If relocate() "relocate"(via create new "return") passed pathname then retrurned result is not being free anywhere in read_alias_file().
>>>>>>>> localealias.c >>>>>>>>>>>>>>>>>>>>>>>>>>

static size_t
internal_function
read_alias_file (const char *fname, int fname_len)
(...)
 #ifdef _LIBC /* Note the file is opened with cancellation in the I/O functions disabled. */ fp = fopen (relocate (full_fname), "rc"); #else fp = fopen (relocate (full_fname), "r"); #endif (...)
} >>>>>>> relocatable.c >>>>>>>>>>>>>>>>>>>>>>>>>>
const char *
relocate (const char *pathname)
{
(...)

char *result =
(char *) xmalloc (curr_prefix_len + strlen (pathname_tail) + 1);


#ifdef NO_XMALLOC
if (result != NULL)
#endif
{
memcpy (result, curr_prefix, curr_prefix_len);
strcpy (result + curr_prefix_len, pathname_tail);
return result;
}
}
}
/* Nothing to relocate. */
return pathname;
}

Simple patch(ofcourse one from many possible) to fix this issue:

--- localealias.c 2012-02-17 15:40:32.191798800 +0100
+++ localealias_new.c 2012-02-17 15:39:09.587796160 +0100
@@ -234,10 +234,13 @@
#ifdef _LIBC
/* Note the file is opened with cancellation in the I/O functions
disabled. */
- fp = fopen (relocate (full_fname), "rc");
+ char* full_fname_new = relocate(full_fname);
+ fp = fopen (full_fname_new, "rc");
#else
- fp = fopen (relocate (full_fname), "r");
+ fp = fopen (full_fname_new, "r");
#endif
+ if (strcmp(full_fname_new, full_fname) != 0)
+ free(full_fname_new);
freea (full_fname);
if (fp == NULL)
return 0;

BR, Łukasz "kosmak" Kołda

reply via email to

[Prev in Thread] Current Thread [Next in Thread]