diff --git a/libpkgconf/dependency.c b/libpkgconf/dependency.c index 3078102..1a4ec68 100644 --- a/libpkgconf/dependency.c +++ b/libpkgconf/dependency.c @@ -56,7 +56,7 @@ static inline pkgconf_dependency_t * pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkgconf_pkg_comparator_t compare) { pkgconf_dependency_t *dep; - char depbuf[PKGCONF_BUFSIZE]; + char depbuf[PKGCONF_ITEM_SIZE]; dep = calloc(sizeof(pkgconf_dependency_t), 1); dep->package = pkgconf_strndup(package, package_sz); @@ -161,7 +161,7 @@ pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *dep { parse_state_t state = OUTSIDE_MODULE; pkgconf_pkg_comparator_t compare = PKGCONF_CMP_ANY; - char cmpname[PKGCONF_BUFSIZE]; + char cmpname[PKGCONF_ITEM_SIZE]; char buf[PKGCONF_BUFSIZE]; size_t package_sz = 0, version_sz = 0; char *start = buf; diff --git a/libpkgconf/fragment.c b/libpkgconf/fragment.c index 4f5ed7f..7576db7 100644 --- a/libpkgconf/fragment.c +++ b/libpkgconf/fragment.c @@ -112,7 +112,7 @@ pkgconf_fragment_munge(const pkgconf_client_t *client, char *buf, size_t buflen, static inline char * pkgconf_fragment_copy_munged(const pkgconf_client_t *client, const char *source) { - char mungebuf[PKGCONF_BUFSIZE]; + char mungebuf[PKGCONF_ITEM_SIZE]; pkgconf_fragment_munge(client, mungebuf, sizeof mungebuf, source, client->sysroot_dir); return strdup(mungebuf); } @@ -148,7 +148,7 @@ pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const } else { - char mungebuf[PKGCONF_BUFSIZE]; + char mungebuf[PKGCONF_ITEM_SIZE]; if (list->tail != NULL && list->tail->data != NULL) { diff --git a/libpkgconf/path.c b/libpkgconf/path.c index b7214fc..2f4cfbb 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -78,7 +78,7 @@ void pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter) { pkgconf_path_t *node; - char path[PKGCONF_BUFSIZE]; + char path[PKGCONF_ITEM_SIZE]; pkgconf_strlcpy(path, text, sizeof path); pkgconf_path_relocate(path, sizeof path); @@ -92,7 +92,7 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter) return; if (S_ISLNK(st.st_mode)) { - char linkdest[PKGCONF_BUFSIZE]; + char linkdest[PKGCONF_ITEM_SIZE]; ssize_t len; memset(linkdest, '\0', sizeof linkdest); @@ -204,7 +204,7 @@ bool pkgconf_path_match_list(const char *path, const pkgconf_list_t *dirlist) { pkgconf_node_t *n = NULL; - char relocated[PKGCONF_BUFSIZE]; + char relocated[PKGCONF_ITEM_SIZE]; const char *cpath = path; pkgconf_strlcpy(relocated, path, sizeof relocated); diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index a35a756..ea970b8 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -35,8 +35,7 @@ # define strcasecmp _stricmp #endif -#define PKG_CONFIG_EXT ".pc" -#define PKG_CONFIG_PATH_SZ (65535) +#define PKG_CONFIG_EXT ".pc" static inline bool str_has_suffix(const char *str, const char *suffix) @@ -287,8 +286,7 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * { pkgconf_pkg_t *pkg; char readbuf[PKGCONF_BUFSIZE]; - char pathbuf[PKGCONF_BUFSIZE]; - char prefixbuf[PKGCONF_BUFSIZE]; + char pathbuf[PKGCONF_ITEM_SIZE]; char *idptr; size_t lineno = 0; @@ -374,7 +372,7 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * pkgconf_tuple_add(client, &pkg->vars, key, value, true); else { - const char *relvalue = determine_prefix(pkg, prefixbuf, sizeof prefixbuf); + const char *relvalue = determine_prefix(pkg, pathbuf, sizeof pathbuf); if (relvalue != NULL) { pkgconf_tuple_add(client, &pkg->vars, "orig_prefix", value, true); @@ -509,8 +507,8 @@ pkgconf_pkg_try_specific_path(pkgconf_client_t *client, const char *path, const { pkgconf_pkg_t *pkg = NULL; FILE *f; - char locbuf[PKG_CONFIG_PATH_SZ]; - char uninst_locbuf[PKG_CONFIG_PATH_SZ]; + char locbuf[PKGCONF_ITEM_SIZE]; + char uninst_locbuf[PKGCONF_ITEM_SIZE]; PKGCONF_TRACE(client, "trying path: %s for %s", path, name); @@ -547,7 +545,7 @@ pkgconf_pkg_scan_dir(pkgconf_client_t *client, const char *path, void *data, pkg for (dirent = readdir(dir); dirent != NULL; dirent = readdir(dir)) { - char filebuf[PKGCONF_BUFSIZE]; + char filebuf[PKGCONF_ITEM_SIZE]; pkgconf_pkg_t *pkg; FILE *f; @@ -634,7 +632,7 @@ pkgconf_pkg_find_in_registry_key(pkgconf_client_t *client, HKEY hkey, const char while (RegEnumValue(key, i++, buf, &bufsize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { - char pathbuf[PKG_CONFIG_PATH_SZ]; + char pathbuf[PKGCONF_ITEM_SIZE]; DWORD type; DWORD pathbuflen = sizeof pathbuf; @@ -669,7 +667,7 @@ pkgconf_pkg_find_in_registry_key(pkgconf_client_t *client, HKEY hkey, const char pkgconf_pkg_t * pkgconf_pkg_find(pkgconf_client_t *client, const char *name) { - char pathbuf[PKGCONF_BUFSIZE]; + char pathbuf[PKGCONF_ITEM_SIZE]; pkgconf_pkg_t *pkg = NULL; pkgconf_node_t *n; FILE *f; @@ -749,7 +747,7 @@ int pkgconf_compare_version(const char *a, const char *b) { char oldch1, oldch2; - char buf1[PKGCONF_BUFSIZE], buf2[PKGCONF_BUFSIZE]; + char buf1[PKGCONF_ITEM_SIZE], buf2[PKGCONF_ITEM_SIZE]; char *str1, *str2; char *one, *two; int ret; diff --git a/libpkgconf/stdinc.h b/libpkgconf/stdinc.h index d0a43ad..3b90853 100644 --- a/libpkgconf/stdinc.h +++ b/libpkgconf/stdinc.h @@ -49,11 +49,18 @@ # else # include # endif +# define PKGCONF_ITEM_SIZE (_MAX_PATH + 1024) #else # define PATH_DEV_NULL "/dev/null" # define SIZE_FMT_SPECIFIER "%zu" # include # include +# include +# ifdef PATH_MAX +# define PKGCONF_ITEM_SIZE (PATH_MAX + 1024) +# else +# define PKGCONF_ITEM_SIZE (4096 + 1024) +# endif #endif #endif diff --git a/libpkgconf/tuple.c b/libpkgconf/tuple.c index 0b22b9a..7fbc71b 100644 --- a/libpkgconf/tuple.c +++ b/libpkgconf/tuple.c @@ -231,7 +231,7 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const *bptr++ = *ptr; else if (*(ptr + 1) == '{') { - char varname[PKGCONF_BUFSIZE]; + char varname[PKGCONF_ITEM_SIZE]; char *vptr = varname; const char *pptr; char *kv, *parsekv; @@ -296,7 +296,7 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const strlen(buf) > strlen(client->sysroot_dir) && strstr(buf + strlen(client->sysroot_dir), client->sysroot_dir) != NULL) { - char cleanpath[PKGCONF_BUFSIZE]; + char cleanpath[PKGCONF_ITEM_SIZE]; pkgconf_strlcpy(cleanpath, buf + strlen(client->sysroot_dir), sizeof cleanpath); pkgconf_path_relocate(cleanpath, sizeof cleanpath);