Compare commits

...

7 Commits

Author SHA1 Message Date
Ariadne Conill 7bfc2289fd tests: add regression test for maximum package count off-by-one
ci/woodpecker/push/woodpecker Pipeline was successful Details
Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
2023-05-02 11:58:56 -07:00
Ariadne Conill 1e179963d4 Enforce maximum package count correctly for --modversion
Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
2023-05-02 11:58:39 -07:00
Harmen Stoppels f7bebba664 fix meson.build
Co-authored-by: Ariadne Conill <ariadne@dereferenced.org>
2023-05-02 11:52:10 -07:00
Harmen Stoppels 434cb2935e use includes 2023-05-02 11:49:34 -07:00
Harmen Stoppels 40638f2472 use AC_CHECK_DECLS to avoid implicit function definition
AC_CHECK_FUNCS is not safe, since implicit function definitions is just
a warning. On 64-bit glibc systems where reallocarray is not defined or
hidden behind macros that are not set, it gets implicitly defined to
return an integer, which is a big problem given that it should return a
pointer, and leads to immediate segfaults.
2023-05-02 11:49:34 -07:00
h30032433 b08733f45d Fix the issue where tests/meson.build was deleted. 2023-05-02 11:48:38 -07:00
huyubiao 6d1f160e89 argvsplit: fix some quoting rules 2023-05-02 11:45:42 -07:00
10 changed files with 36 additions and 16 deletions

View File

@ -135,7 +135,8 @@ test_scripts= tests/meson.build \
tests/sysroot.sh \
tests/version.sh
check_SCRIPTS= $(test_scripts:.sh=)
test_sh = $(filter-out tests/meson.build, $(test_scripts))
check_SCRIPTS = $(test_sh:.sh=)
SUFFIXES= .sh

View File

@ -1325,7 +1325,7 @@ cleanup3:
/* check if there is a limit to the number of packages allowed to be included, if so and we have hit
* the limit, stop adding packages to the queue.
*/
if (maximum_package_count > 0 && pkgq.length > maximum_package_count)
if (maximum_package_count > 0 && pkgq.length >= maximum_package_count)
break;
while (isspace((unsigned char)package[0]))

View File

@ -22,7 +22,8 @@ AX_CHECK_COMPILE_FLAG([-std=gnu99], [CFLAGS="$CFLAGS -std=gnu99"], [
AX_CHECK_COMPILE_FLAG([-std=c99], [CFLAGS="$CFLAGS -std=c99"])
])
AC_CONFIG_HEADERS([libpkgconf/config.h])
AC_CHECK_FUNCS([strlcpy strlcat strndup reallocarray])
AC_CHECK_DECLS([strlcpy, strlcat, strndup], [], [], [[#include <string.h>]])
AC_CHECK_DECLS([reallocarray])
AC_CHECK_HEADERS([sys/stat.h])
AM_INIT_AUTOMAKE([foreign dist-xz subdir-objects])
AM_SILENT_RULES([yes])

View File

@ -89,11 +89,6 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv)
}
else
{
/* If we are outside a quoted string/char, an escaped space is usually used to
preserve spaces in file names. */
if (!(*src_iter == '$' || *src_iter == '`' || *src_iter == '"' || *src_iter == '\\' || *src_iter == ' '))
*dst_iter++ = '\\';
*dst_iter++ = *src_iter;
}

View File

@ -25,7 +25,7 @@
#include <libpkgconf/bsdstubs.h>
#include <libpkgconf/config.h>
#ifndef HAVE_STRLCPY
#if !HAVE_DECL_STRLCPY
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
@ -58,7 +58,7 @@ strlcpy(char *dst, const char *src, size_t siz)
}
#endif
#ifndef HAVE_STRLCAT
#if !HAVE_DECL_STRLCAT
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
@ -107,7 +107,7 @@ strlcat(char *dst, const char *src, size_t siz)
* from the use of this software.
*/
#ifndef HAVE_STRNDUP
#if !HAVE_DECL_STRNDUP
/*
* Creates a memory buffer and copies at most 'len' characters to it.
* If 'len' is less than the length of the source string, truncation occured.
@ -139,7 +139,7 @@ pkgconf_strndup(const char *src, size_t len)
return strndup(src, len);
}
#ifndef HAVE_REALLOCARRAY
#if !HAVE_DECL_REALLOCARRAY
void *
reallocarray(void *ptr, size_t m, size_t n)
{

View File

@ -12,6 +12,18 @@
/* Define to 1 if you have the `reallocarray' function. */
#mesondefine HAVE_REALLOCARRAY
/* Define to 1 if you have the `strlcat' function. */
#mesondefine HAVE_DECL_STRLCAT
/* Define to 1 if you have the `strlcpy' function. */
#mesondefine HAVE_DECL_STRLCPY
/* Define to 1 if you have the `strndup' function. */
#mesondefine HAVE_DECL_STRNDUP
/* Define to 1 if you have the `reallocarray' function. */
#mesondefine HAVE_DECL_REALLOCARRAY
/* Name of package */
#mesondefine PACKAGE

View File

@ -30,8 +30,12 @@ check_functions = [
]
foreach f : check_functions
name = f[0].to_upper().underscorify()
if cc.has_function(f[0], prefix : '#define _BSD_SOURCE\n#include <@0@>'.format(f[1])) and cc.has_header_symbol(f[1], f[0], prefix : '#define _BSD_SOURCE')
cdata.set('HAVE_@0@'.format(f[0].to_upper().underscorify()), 1)
cdata.set('HAVE_@0@'.format(name), 1)
cdata.set('HAVE_DECL_@0@'.format(name), 1)
else
cdata.set('HAVE_DECL_@0@'.format(name), 0)
endif
endforeach

View File

@ -7,4 +7,4 @@ Name: quotes
Description: A testing pkg-config file
Version: 1.2.3
Libs: -L${libdir} -lfoo
Cflags: -DQUOTED=\"bla\"
Cflags: -DQUOTED=\"bla\" -DA=\"escaped\ string\'\ \literal\" -DB="\1\$" -DC='bla'

View File

@ -142,7 +142,7 @@ quoted_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-DQUOTED=\\\"bla\\\"\n" \
-o inline:"-DQUOTED=\\\"bla\\\" -DA=\\\"escaped\\ string\\\'\\ literal\\\" -DB=\\\\\\1\$ -DC=bla\n" \
pkgconf --cflags quotes
}

View File

@ -31,7 +31,8 @@ tests_init \
explicit_sysroot \
empty_tuple \
solver_requires_private_debounce \
billion_laughs
billion_laughs \
maximum_package_depth_off_by_one
# sysroot_munge \
@ -273,3 +274,9 @@ billion_laughs_body()
atf_check -o inline:"warning: truncating very long variable to 64KB\nwarning: truncating very long variable to 64KB\nwarning: truncating very long variable to 64KB\nwarning: truncating very long variable to 64KB\nwarning: truncating very long variable to 64KB\n" \
pkgconf --with-path="${selfdir}/lib1" --validate billion-laughs
}
maximum_package_depth_off_by_one_body()
{
atf_check -o inline:"1.2.3\n" \
pkgconf --with-path="${selfdir}/lib1" --modversion foo bar baz
}