Browse Source

[libxdg-basedir] Add patches

nsITobin 3 weeks ago
parent
commit
4166c3b7d6

+ 1 - 1
libxdg-basedir/libxdg-basedir-basedir-bounds-error.patch

@@ -10,4 +10,4 @@ index 68ab879..1a2a8c4 100644
 +		if (!(relhome = (char*)malloc((homelen = strlen(home))+fallbacklength+1))) return NULL;
  		memcpy(relhome, home, homelen);
  		memcpy(relhome+homelen, relativefallback, fallbacklength+1);
- 	}
+ 	}

+ 145 - 0
libxdg-basedir/libxdg-basedir-home-undef.patch

@@ -0,0 +1,145 @@
+--- a/src/basedir.c	2019-04-01 17:11:52.293770606 +0200
++++ b/src/basedir.c	2019-04-01 14:03:23.465154736 +0200
+@@ -142,26 +142,22 @@
+ /** Free all data in the cache and set pointers to null. */
+ static void xdgFreeData(xdgCachedData *cache)
+ {
+-	if (cache->dataHome);
+-	{
++        if (cache->dataHome) {
+ 		/* the first element of the directory lists is usually the home directory */
+ 		if (cache->searchableDataDirectories && cache->searchableDataDirectories[0] != cache->dataHome)
+ 			free(cache->dataHome);
+ 		cache->dataHome = 0;
+ 	}
+-	if (cache->configHome);
+-	{
++	if (cache->configHome) {
+ 		if (cache->searchableConfigDirectories && cache->searchableConfigDirectories[0] != cache->configHome)
+ 			free(cache->configHome);
+ 		cache->configHome = 0;
+ 	}
+-	if (cache->cacheHome)
+-	{
++	if (cache->cacheHome) {
+ 		free(cache->cacheHome);
+ 		cache->cacheHome = 0;
+ 	}
+-	if (cache->runtimeDirectory)
+-	{
++	if (cache->runtimeDirectory) {
+ 		free(cache->runtimeDirectory);
+ 		cache->runtimeDirectory = 0;
+ 	}
+@@ -327,8 +323,12 @@
+ 
+ 	if (cache->dataHome && cache->configHome && cache->cacheHome) return TRUE;
+ 
+-	if (!(homeenv = xdgGetEnv("HOME")))
+-		return FALSE;
++	if (!(homeenv = xdgGetEnv("HOME"))) {
++          cache->dataHome = NULL;
++          cache->configHome = NULL;
++          cache->cacheHome = NULL;
++          return TRUE;
++        }
+ 
+ 	/* Allocate maximum needed for any of the 3 default values */
+ 	if (!(value = (char*)malloc((homelen = strlen(homeenv))+extralen))) return FALSE;
+@@ -614,8 +614,8 @@
+ 	else
+ 	{
+ 		char *datahome = (char*)xdgDataHome(NULL);
+-		char **datadirs = 0;
+-		if (datahome && !(datadirs = xdgGetDirectoryLists("XDG_DATA_DIRS", datahome, DefaultDataDirectoriesList)))
++		char **datadirs = xdgGetDirectoryLists("XDG_DATA_DIRS", datahome, DefaultDataDirectoriesList);
++		if (datahome && !datadirs)
+ 			free(datahome);
+ 		return (const char * const *)datadirs;
+ 	}
+@@ -634,8 +634,8 @@
+ 	else
+ 	{
+ 		char *confighome = (char*)xdgConfigHome(NULL);
+-		char **configdirs = 0;
+-		if (confighome && !(configdirs = xdgGetDirectoryLists("XDG_CONFIG_DIRS", confighome, DefaultConfigDirectoriesList)))
++		char **configdirs = xdgGetDirectoryLists("XDG_CONFIG_DIRS", confighome, DefaultConfigDirectoriesList);
++		if (confighome && !configdirs)
+ 			free(confighome);
+ 		return (const char * const *)configdirs;
+ 	}
+--- a/tests/testdump.c	2012-01-22 02:29:11.000000000 +0100
++++ b/tests/testdump.c	2019-04-01 14:03:23.463154767 +0200
+@@ -24,27 +24,56 @@
+ 
+ #include <basedir.h>
+ #include <stdio.h>
++#include <stdlib.h>
++
++static void print_item_list(const char * const * item_list, int do_free)
++{
++  const char * const * item;
++  for (item = item_list; *item; item++) {
++    printf("%s%c", *item, (item[1] ? ':' : '\n'));
++    if (do_free) free((void *)*item);
++  }
++  if (do_free) free((void *)item_list);
++}
++
++static void do_test(xdgHandle *handle) {
++  int do_free = (handle == NULL);
++
++  char *dataHome = xdgDataHome(handle);
++  printf("${XDG_DATA_HOME:-$HOME/.local/share}=%s\n", dataHome);
++  if (do_free) free(dataHome);
++
++  char *configHome = xdgConfigHome(handle);
++  printf("${XDG_CONFIG_HOME:-$HOME/.config}=%s\n", configHome);
++  if (do_free) free(configHome);
++
++  printf("${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}=");
++  print_item_list(xdgDataDirectories(handle), do_free);
++
++  printf("${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}=");
++  print_item_list(xdgSearchableDataDirectories(handle), do_free);
++
++  printf("${XDG_CONFIG_DIRS:-/etc/xdg}=");
++  print_item_list(xdgConfigDirectories(handle), do_free);
++
++  printf("${XDG_CONFIG_HOME:-$HOME/.config}:${XDG_CONFIG_DIRS:-/etc/xdg}=");
++  print_item_list(xdgSearchableConfigDirectories(handle), do_free);
++
++  char *cacheHome = xdgCacheHome(handle);
++  printf("${XDG_CACHE_HOME:-$HOME/.cache}=%s\n", cacheHome);
++  if (do_free) free(cacheHome);
++}
+ 
+ int main(int argc, char* argv[])
+ {
+-	const char * const * item;
+ 	xdgHandle handle;
++
++        printf("UNCACHED\n");
++        do_test(0);
+ 	if (!xdgInitHandle(&handle)) return 1;
+-	printf("${XDG_DATA_HOME:-$HOME/.local/share}=%s\n", xdgDataHome(&handle));
+-	printf("${XDG_CONFIG_HOME:-$HOME/.config}=%s\n", xdgConfigHome(&handle));
+-	printf("${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}=");
+-	for (item = xdgDataDirectories(&handle); *item; item++)
+-		printf("%s%c", *item, (item[1] ? ':' : '\n'));
+-	printf("${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}=");
+-	for (item = xdgSearchableDataDirectories(&handle); *item; item++)
+-		printf("%s%c", *item, (item[1] ? ':' : '\n'));
+-	printf("${XDG_CONFIG_DIRS:-/etc/xdg}=");
+-	for (item = xdgConfigDirectories(&handle); *item; item++)
+-		printf("%s%c", *item, (item[1] ? ':' : '\n'));
+-	printf("${XDG_CONFIG_HOME:-$HOME/.config}:${XDG_CONFIG_DIRS:-/etc/xdg}=");
+-	for (item = xdgSearchableConfigDirectories(&handle); *item; item++)
+-		printf("%s%c", *item, (item[1] ? ':' : '\n'));
+-	printf("${XDG_CACHE_HOME:-$HOME/.cache}=%s\n", xdgCacheHome(&handle));
++        printf("CACHED\n");
++        do_test(&handle);
+ 	xdgWipeHandle(&handle);
++        printf("DONE\n");
+ 	return 0;
+ }

+ 14 - 0
libxdg-basedir/libxdg-basedir-leak.patch

@@ -0,0 +1,14 @@
+--- libxdg-basedir-1.2.0/src/basedir.c	2012-01-22 02:29:11.000000000 +0100
++++ libxdg-basedir-1.2.0/src/basedir.c	2013-10-13 00:55:11.174671212 +0200
+@@ -160,6 +160,11 @@
+ 		free(cache->cacheHome);
+ 		cache->cacheHome = 0;
+ 	}
++	if (cache->runtimeDirectory)
++	{
++		free(cache->runtimeDirectory);
++		cache->runtimeDirectory = 0;
++	}
+ 	xdgFreeStringList(cache->searchableDataDirectories);
+ 	cache->searchableDataDirectories = 0;
+ 	xdgFreeStringList(cache->searchableConfigDirectories);

+ 11 - 0
libxdg-basedir/libxdg-basedir-valgrind-libtool.patch

@@ -0,0 +1,11 @@
+--- a/tests/query-harness.sh
++++ b/tests/query-harness.sh
+@@ -10,7 +10,7 @@ fi
+ testquery="${top_builddir}/tests/testquery"
+ if [ -n "$USE_VALGRIND" ] && (type valgrind 1>/dev/null)
+ then
+-	output="`valgrind -q --error-exitcode=1 "$testquery" $arguments`"
++	output="`libtool --mode=execute valgrind -q --error-exitcode=1 "$testquery" $arguments`"
+ else
+ 	output="`"$testquery" $arguments`"
+ fi