diff --git a/bin/xbps-alternatives/main.c b/bin/xbps-alternatives/main.c index 853640135..92b8afe72 100644 --- a/bin/xbps-alternatives/main.c +++ b/bin/xbps-alternatives/main.c @@ -230,9 +230,9 @@ main(int argc, char **argv) memset(&xh, 0, sizeof(xh)); xh.state_cb = state_cb; if (rootdir) - xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); + strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); if (confdir) - xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); + strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); xh.flags = flags; diff --git a/bin/xbps-checkvers/main.c b/bin/xbps-checkvers/main.c index c63c4df0d..b8c378c34 100644 --- a/bin/xbps-checkvers/main.c +++ b/bin/xbps-checkvers/main.c @@ -113,10 +113,10 @@ rcv_init(rcv_t *rcv, const char *prog) assert(rcv->cache); if (rcv->xbps_conf != NULL) { - xbps_strlcpy(rcv->xhp.confdir, rcv->xbps_conf, sizeof(rcv->xhp.confdir)); + strlcpy(rcv->xhp.confdir, rcv->xbps_conf, sizeof(rcv->xhp.confdir)); } if (rcv->rootdir != NULL) { - xbps_strlcpy(rcv->xhp.rootdir, rcv->rootdir, sizeof(rcv->xhp.rootdir)); + strlcpy(rcv->xhp.rootdir, rcv->rootdir, sizeof(rcv->xhp.rootdir)); } if (xbps_init(&rcv->xhp) != 0) abort(); @@ -820,8 +820,8 @@ main(int argc, char **argv) if ((p = strrchr(argv[i], '/')) && (strcmp(p, "/template")) == 0) { tmpl = argv[i]; } else { - xbps_strlcat(tmp, argv[i], sizeof tmp); - xbps_strlcat(tmp, "/template", sizeof tmp); + strlcat(tmp, argv[i], sizeof tmp); + strlcat(tmp, "/template", sizeof tmp); tmpl = tmp; } rcv_process_file(&rcv, tmpl, rcv_check_version); diff --git a/bin/xbps-dgraph/main.c b/bin/xbps-dgraph/main.c index 5f6eee08e..59b5dbbb0 100644 --- a/bin/xbps-dgraph/main.c +++ b/bin/xbps-dgraph/main.c @@ -598,9 +598,9 @@ main(int argc, char **argv) /* Initialize libxbps */ memset(&xh, 0, sizeof(xh)); if (rootdir != NULL) - xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); + strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); if (confdir) - xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); + strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); xh.flags = flags; if ((rv = xbps_init(&xh)) != 0) diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index c7eb56595..a6f8e3039 100644 --- a/bin/xbps-install/main.c +++ b/bin/xbps-install/main.c @@ -216,11 +216,11 @@ main(int argc, char **argv) xh.fetch_cb = fetch_file_progress_cb; xh.fetch_cb_data = &xfer; if (rootdir) - xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); + strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); if (cachedir) - xbps_strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir)); + strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir)); if (confdir) - xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); + strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); xh.flags = flags; if (flags & XBPS_FLAG_VERBOSE) xh.unpack_cb = unpack_progress_cb; diff --git a/bin/xbps-pkgdb/main.c b/bin/xbps-pkgdb/main.c index e0b7091c7..a33e06f8f 100644 --- a/bin/xbps-pkgdb/main.c +++ b/bin/xbps-pkgdb/main.c @@ -144,9 +144,9 @@ main(int argc, char **argv) memset(&xh, 0, sizeof(xh)); if (rootdir) - xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); + strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); if (confdir) - xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); + strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); xh.flags = flags; if ((rv = xbps_init(&xh)) != 0) { diff --git a/bin/xbps-query/main.c b/bin/xbps-query/main.c index 73cc84060..103ef7838 100644 --- a/bin/xbps-query/main.c +++ b/bin/xbps-query/main.c @@ -241,11 +241,11 @@ main(int argc, char **argv) * Initialize libxbps. */ if (rootdir) - xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); + strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); if (cachedir) - xbps_strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir)); + strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir)); if (confdir) - xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); + strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); xh.flags = flags; diff --git a/bin/xbps-reconfigure/main.c b/bin/xbps-reconfigure/main.c index ea0f2afcb..8b50c0b76 100644 --- a/bin/xbps-reconfigure/main.c +++ b/bin/xbps-reconfigure/main.c @@ -168,9 +168,9 @@ main(int argc, char **argv) memset(&xh, 0, sizeof(xh)); xh.state_cb = state_cb; if (rootdir) - xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); + strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); if (confdir) - xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); + strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); xh.flags = flags; diff --git a/bin/xbps-remove/clean-cache.c b/bin/xbps-remove/clean-cache.c index fb993820d..7606122a7 100644 --- a/bin/xbps-remove/clean-cache.c +++ b/bin/xbps-remove/clean-cache.c @@ -43,7 +43,7 @@ static int binpkg_parse(char *buf, size_t bufsz, const char *path, const char **pkgver, const char **arch) { char *p; - size_t n = xbps_strlcpy(buf, path, bufsz); + size_t n = strlcpy(buf, path, bufsz); if (n >= bufsz) return -ENOBUFS; diff --git a/bin/xbps-remove/main.c b/bin/xbps-remove/main.c index 4b2b8d6bf..6470cc36f 100644 --- a/bin/xbps-remove/main.c +++ b/bin/xbps-remove/main.c @@ -251,11 +251,11 @@ main(int argc, char **argv) memset(&xh, 0, sizeof(xh)); xh.state_cb = state_cb_rm; if (rootdir) - xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); + strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); if (cachedir) - xbps_strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir)); + strlcpy(xh.cachedir, cachedir, sizeof(xh.cachedir)); if (confdir) - xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); + strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); xh.flags = flags; diff --git a/bin/xbps-uhelper/main.c b/bin/xbps-uhelper/main.c index 84eca5bf7..edc1fb850 100644 --- a/bin/xbps-uhelper/main.c +++ b/bin/xbps-uhelper/main.c @@ -146,9 +146,9 @@ main(int argc, char **argv) xh.fetch_cb_data = &xfer; xh.flags = flags; if (rootdir) - xbps_strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); + strlcpy(xh.rootdir, rootdir, sizeof(xh.rootdir)); if (confdir) - xbps_strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); + strlcpy(xh.confdir, confdir, sizeof(xh.confdir)); if ((rv = xbps_init(&xh)) != 0) { xbps_error_printf("xbps-uhelper: failed to " "initialize libxbps: %s.\n", strerror(rv)); diff --git a/configure b/configure index ba8c44578..516a32ba0 100755 --- a/configure +++ b/configure @@ -195,7 +195,7 @@ echo "CC = $CC" >>$CONFIG_MK echo "CFLAGS = -O2" >>$CONFIG_MK echo "LDFLAGS = -L\$(TOPDIR)/lib" >>$CONFIG_MK -echo "CPPFLAGS = -I. -I\$(TOPDIR) -I\$(TOPDIR)/include" >>$CONFIG_MK +echo "CPPFLAGS = -I\$(TOPDIR)/lib/compat -I. -I\$(TOPDIR) -I\$(TOPDIR)/include" >>$CONFIG_MK echo "CPPFLAGS += -DXBPS_SYSCONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK echo "CPPFLAGS += -DXBPS_SYSDEFCONF_PATH=\\\"${SHAREDIR}/xbps.d\\\"" >>$CONFIG_MK echo "CPPFLAGS += -DXBPS_VERSION=\\\"${VERSION}\\\"" >>$CONFIG_MK diff --git a/include/compat.h b/include/compat.h index 80528d595..f030cc70a 100644 --- a/include/compat.h +++ b/include/compat.h @@ -8,21 +8,6 @@ #include "macro.h" -#ifndef HAVE_STRLCAT -size_t HIDDEN strlcat(char *, const char *, size_t); -#endif - -#ifndef HAVE_STRLCPY -size_t HIDDEN strlcpy(char *, const char *, size_t); -#endif - -#ifndef HAVE_STRCASESTR -char HIDDEN *strcasestr(const char *, const char *); -#endif - -#ifndef HAVE_VASPRINTF -int HIDDEN vasprintf(char **, const char *, va_list); -#endif #ifndef HAVE_HUMANIZE_NUMBER #define HN_DECIMAL 0x01 diff --git a/lib/compat/stdio.h b/lib/compat/stdio.h new file mode 100644 index 000000000..ca951d91d --- /dev/null +++ b/lib/compat/stdio.h @@ -0,0 +1,10 @@ +#ifndef XBPS_COMPAT_STDIO_H +#define XBPS_COMPAT_STDIO_H + +#include_next + +#ifndef HAVE_VASPRINTF +int vasprintf(char **, const char *, va_list); +#endif + +#endif /*!XBPS_COMPAT_STDIO_H*/ diff --git a/lib/compat/string.h b/lib/compat/string.h new file mode 100644 index 000000000..7bb18eeab --- /dev/null +++ b/lib/compat/string.h @@ -0,0 +1,18 @@ +#ifndef XBPS_COMPAT_STRING_H +#define XBPS_COMPAT_STRING_H + +#include_next + +#ifndef HAVE_STRLCAT +size_t strlcat(char *, const char *, size_t); +#endif + +#ifndef HAVE_STRLCPY +size_t strlcpy(char *, const char *, size_t); +#endif + +#ifndef HAVE_STRCASESTR +char *strcasestr(const char *, const char *); +#endif + +#endif /*!XBPS_COMPAT_STRING_H*/ diff --git a/lib/compat/strlcat.c b/lib/compat/strlcat.c index ff2731146..c94e90dee 100644 --- a/lib/compat/strlcat.c +++ b/lib/compat/strlcat.c @@ -1,7 +1,7 @@ -/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */ +/* $OpenBSD: strlcat.c,v 1.19 2019/01/25 00:19:25 millert Exp $ */ /* - * Copyright (c) 1998 Todd C. Miller + * Copyright (c) 1998, 2015 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -19,39 +19,37 @@ #include #include -#include "compat.h" - /* - * 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 - * will be copied. Always NUL terminates (unless siz <= strlen(dst)). - * Returns strlen(src) + MIN(siz, strlen(initial dst)). - * If retval >= siz, truncation occurred. + * Appends src to string dst of size dsize (unlike strncat, dsize is the + * full size of dst, not space left). At most dsize-1 characters + * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). + * Returns strlen(src) + MIN(dsize, strlen(initial dst)). + * If retval >= dsize, truncation occurred. */ -size_t HIDDEN -strlcat(char *dst, const char *src, size_t siz) +size_t +strlcat(char *dst, const char *src, size_t dsize) { - char *d = dst; - const char *s = src; - size_t n = siz; + const char *odst = dst; + const char *osrc = src; + size_t n = dsize; size_t dlen; - /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0 && *d != '\0') - d++; - dlen = d - dst; - n = siz - dlen; + /* Find the end of dst and adjust bytes left but don't go past end. */ + while (n-- != 0 && *dst != '\0') + dst++; + dlen = dst - odst; + n = dsize - dlen; - if (n == 0) - return(dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; + if (n-- == 0) + return(dlen + strlen(src)); + while (*src != '\0') { + if (n != 0) { + *dst++ = *src; n--; } - s++; + src++; } - *d = '\0'; + *dst = '\0'; - return(dlen + (s - src)); /* count does not include NUL */ + return(dlen + (src - osrc)); /* count does not include NUL */ } diff --git a/lib/compat/strlcpy.c b/lib/compat/strlcpy.c index 0915199a0..2fa498c39 100644 --- a/lib/compat/strlcpy.c +++ b/lib/compat/strlcpy.c @@ -1,7 +1,7 @@ -/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */ +/* $OpenBSD: strlcpy.c,v 1.16 2019/01/25 00:19:25 millert Exp $ */ /* - * Copyright (c) 1998 Todd C. Miller + * Copyright (c) 1998, 2015 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -19,35 +19,32 @@ #include #include -#include "compat.h" - /* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. + * Copy string src to buffer dst of size dsize. At most dsize-1 + * chars will be copied. Always NUL terminates (unless dsize == 0). + * Returns strlen(src); if retval >= dsize, truncation occurred. */ -size_t HIDDEN -strlcpy(char *dst, const char *src, size_t siz) +size_t +strlcpy(char *dst, const char *src, size_t dsize) { - char *d = dst; - const char *s = src; - size_t n = siz; + const char *osrc = src; + size_t nleft = dsize; - /* Copy as many bytes as will fit */ - if (n != 0) { - while (--n != 0) { - if ((*d++ = *s++) == '\0') + /* Copy as many bytes as will fit. */ + if (nleft != 0) { + while (--nleft != 0) { + if ((*dst++ = *src++) == '\0') break; } } - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) + /* Not enough room in dst, add NUL and traverse rest of src. */ + if (nleft == 0) { + if (dsize != 0) + *dst = '\0'; /* NUL-terminate dst */ + while (*src++) ; } - return(s - src - 1); /* count does not include NUL */ + return(src - osrc - 1); /* count does not include NUL */ } diff --git a/lib/conf.c b/lib/conf.c index 62adfddf4..49bd9af5d 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -109,7 +109,7 @@ store_preserved_file(struct xbps_handle *xhp, const char *file) len = strlen(globbuf.gl_pathv[i]) - strlen(xhp->rootdir) + 1; p = malloc(len); assert(p); - xbps_strlcpy(p, globbuf.gl_pathv[i] + strlen(xhp->rootdir), len); + strlcpy(p, globbuf.gl_pathv[i] + strlen(xhp->rootdir), len); xbps_array_add_cstring(xhp->preserved_files, p); xbps_dbg_printf("Added preserved file: %s (expanded from %s)\n", p, file); free(p); diff --git a/lib/download.c b/lib/download.c index 21d5a8933..3e3fc7e20 100644 --- a/lib/download.c +++ b/lib/download.c @@ -122,7 +122,7 @@ xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char memset(&fetch_flags, 0, sizeof(fetch_flags)); if (flags != NULL) - xbps_strlcpy(fetch_flags, flags, 7); + strlcpy(fetch_flags, flags, 7); tempfile = xbps_xasprintf("%s.part", filename); /* @@ -145,7 +145,7 @@ xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char if (stat(filename, &st) == 0) { refetch = true; url->last_modified = st.st_mtime; - xbps_strlcat(fetch_flags, "i", sizeof(fetch_flags)); + strlcat(fetch_flags, "i", sizeof(fetch_flags)); } else { if (errno != ENOENT) { rv = -1; diff --git a/lib/external/dewey.c b/lib/external/dewey.c index 585314724..80977d9ce 100644 --- a/lib/external/dewey.c +++ b/lib/external/dewey.c @@ -331,7 +331,7 @@ dewey_match(const char *pattern, const char *pkg) if (sep2) { char ver[PKG_PATTERN_MAX]; - xbps_strlcpy(ver, sep, MIN((ssize_t)sizeof(ver), sep2-sep+1)); + strlcpy(ver, sep, MIN((ssize_t)sizeof(ver), sep2-sep+1)); if (dewey_cmp(version, op, ver)) return 1; } else { diff --git a/lib/initend.c b/lib/initend.c index 3e73a1fcb..d191a2e6f 100644 --- a/lib/initend.c +++ b/lib/initend.c @@ -114,7 +114,7 @@ xbps_init(struct xbps_handle *xhp) /* allow to overwrite uname(3) and conf file with env variable */ if ((native_arch = getenv("XBPS_ARCH")) && *native_arch != '\0') { - if (xbps_strlcpy(xhp->native_arch, native_arch, + if (strlcpy(xhp->native_arch, native_arch, sizeof xhp->native_arch) >= sizeof xhp->native_arch) return ENOBUFS; } @@ -123,7 +123,7 @@ xbps_init(struct xbps_handle *xhp) struct utsname un; if (uname(&un) == -1) return ENOTSUP; - if (xbps_strlcpy(xhp->native_arch, un.machine, + if (strlcpy(xhp->native_arch, un.machine, sizeof xhp->native_arch) >= sizeof xhp->native_arch) return ENOBUFS; } diff --git a/lib/util.c b/lib/util.c index 04d715157..2e29d4d5e 100644 --- a/lib/util.c +++ b/lib/util.c @@ -511,24 +511,6 @@ xbps_humanize_number(char *buf, int64_t bytes) HN_AUTOSCALE, HN_DECIMAL|HN_NOSPACE); } -size_t -xbps_strlcat(char *dest, const char *src, size_t siz) -{ - assert(dest); - assert(src); - - return strlcat(dest, src, siz); -} - -size_t -xbps_strlcpy(char *dest, const char *src, size_t siz) -{ - assert(dest); - assert(src); - - return strlcpy(dest, src, siz); -} - /* * Check if pkg is explicitly marked to replace a specific installed version. */ diff --git a/lib/util_path.c b/lib/util_path.c index 2f0e05864..f8704b2fa 100644 --- a/lib/util_path.c +++ b/lib/util_path.c @@ -75,7 +75,7 @@ xbps_path_clean(char *dst) char *d = dst; bool rooted = *dst == '/'; - if (xbps_strlcpy(buf, dst, sizeof buf) >= sizeof buf) + if (strlcpy(buf, dst, sizeof buf) >= sizeof buf) return -1; if (rooted) { @@ -140,8 +140,8 @@ xbps_path_rel(char *dst, size_t dstlen, const char *from, const char *to) *dst = '\0'; - if (xbps_strlcpy(frombuf, from, sizeof frombuf) >= sizeof frombuf || - xbps_strlcpy(tobuf, to, sizeof tobuf) >= sizeof tobuf) + if (strlcpy(frombuf, from, sizeof frombuf) >= sizeof frombuf || + strlcpy(tobuf, to, sizeof tobuf) >= sizeof tobuf) return -1; if (xbps_path_clean(frombuf) == -1 || xbps_path_clean(tobuf) == -1) @@ -185,7 +185,7 @@ xbps_path_vjoin(char *dst, size_t dstlen, va_list ap) for (;;) { size_t n; - if ((n = xbps_strlcat(dst+len, val, dstlen-len)) >= dstlen-len) + if ((n = strlcat(dst+len, val, dstlen-len)) >= dstlen-len) goto err; len += n; if ((val = va_arg(ap, const char *)) == NULL) @@ -227,7 +227,7 @@ xbps_path_append(char *dst, size_t dstlen, const char *suffix) goto out; if (*dst == '\0') { - if ((len = xbps_strlcpy(dst, suffix, dstlen)) >= dstlen) + if ((len = strlcpy(dst, suffix, dstlen)) >= dstlen) goto err; goto out; } @@ -239,7 +239,7 @@ xbps_path_append(char *dst, size_t dstlen, const char *suffix) if (*suffix == '/') suffix++; - if ((len = xbps_strlcat(dst, suffix, dstlen)) >= dstlen) + if ((len = strlcat(dst, suffix, dstlen)) >= dstlen) goto err; out: return (ssize_t)len < 0 ? -1 : (ssize_t)len; @@ -260,7 +260,7 @@ xbps_path_prepend(char *dst, size_t dstlen, const char *prefix) goto out; if (*dst == '\0') { - if ((len = xbps_strlcpy(dst, prefix, dstlen)) >= dstlen) + if ((len = strlcpy(dst, prefix, dstlen)) >= dstlen) goto err; goto out; } diff --git a/tests/xbps/libxbps/config/main.c b/tests/xbps/libxbps/config/main.c index 4b45ddc6f..10304dde7 100644 --- a/tests/xbps/libxbps/config/main.c +++ b/tests/xbps/libxbps/config/main.c @@ -47,8 +47,8 @@ ATF_TC_BODY(config_include_test, tc) memset(&xh, 0, sizeof(xh)); buf = getcwd(pwd, sizeof(pwd)); - xbps_strlcpy(xh.rootdir, pwd, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, pwd, sizeof(xh.metadir)); + strlcpy(xh.rootdir, pwd, sizeof(xh.rootdir)); + strlcpy(xh.metadir, pwd, sizeof(xh.metadir)); ret = snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd); ATF_REQUIRE_EQ((ret >= 0), 1); ATF_REQUIRE_EQ(((size_t)ret < sizeof(xh.confdir)), 1); @@ -99,8 +99,8 @@ ATF_TC_BODY(config_include_nomatch_test, tc) memset(&xh, 0, sizeof(xh)); buf = getcwd(pwd, sizeof(pwd)); - xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); + strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); + strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); ret = snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd); ATF_REQUIRE_EQ((ret >= 0), 1); ATF_REQUIRE_EQ(((size_t)ret < sizeof(xh.confdir)), 1); @@ -139,8 +139,8 @@ ATF_TC_BODY(config_include_absolute, tc) memset(&xh, 0, sizeof(xh)); buf = getcwd(pwd, sizeof(pwd)); - xbps_strlcpy(xh.rootdir, pwd, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, pwd, sizeof(xh.metadir)); + strlcpy(xh.rootdir, pwd, sizeof(xh.rootdir)); + strlcpy(xh.metadir, pwd, sizeof(xh.metadir)); ret = snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd); ATF_REQUIRE_EQ((ret >= 0), 1); ATF_REQUIRE_EQ(((size_t)ret < sizeof(xh.confdir)), 1); @@ -187,8 +187,8 @@ ATF_TC_BODY(config_include_absolute_glob, tc) memset(&xh, 0, sizeof(xh)); buf = getcwd(pwd, sizeof(pwd)); - xbps_strlcpy(xh.rootdir, pwd, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, pwd, sizeof(xh.metadir)); + strlcpy(xh.rootdir, pwd, sizeof(xh.rootdir)); + strlcpy(xh.metadir, pwd, sizeof(xh.metadir)); ret = snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd); ATF_REQUIRE_EQ((ret >= 0), 1); ATF_REQUIRE_EQ(((size_t)ret < sizeof(xh.confdir)), 1); @@ -241,8 +241,8 @@ ATF_TC_BODY(config_masking, tc) memset(&xh, 0, sizeof(xh)); buf = getcwd(pwd, sizeof(pwd)); - xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); + strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); + strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); ret = snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd); ATF_REQUIRE_EQ((ret >= 0), 1); ATF_REQUIRE_EQ(((size_t)ret < sizeof(xh.confdir)), 1); @@ -295,8 +295,8 @@ ATF_TC_BODY(config_trim_values, tc) memset(&xh, 0, sizeof(xh)); buf = getcwd(pwd, sizeof(pwd)); - xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); + strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); + strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); ret = snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd); ATF_REQUIRE_EQ((ret >= 0), 1); ATF_REQUIRE_EQ(((size_t)ret < sizeof(xh.confdir)), 1); @@ -346,8 +346,8 @@ ATF_TC_BODY(config_no_trailing_newline, tc) memset(&xh, 0, sizeof(xh)); buf = getcwd(pwd, sizeof(pwd)); - xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); + strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); + strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); ret = snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd); ATF_REQUIRE_EQ((ret >= 0), 1); ATF_REQUIRE_EQ(((size_t)ret < sizeof(xh.confdir)), 1); diff --git a/tests/xbps/libxbps/find_pkg_orphans/main.c b/tests/xbps/libxbps/find_pkg_orphans/main.c index 8ec47eecb..ad082b5dc 100644 --- a/tests/xbps/libxbps/find_pkg_orphans/main.c +++ b/tests/xbps/libxbps/find_pkg_orphans/main.c @@ -67,8 +67,8 @@ ATF_TC_BODY(find_pkg_orphans_test, tc) tcsdir = atf_tc_get_config_var(tc, "srcdir"); memset(&xh, 0, sizeof(xh)); - xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); + strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); + strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); ATF_REQUIRE_EQ(xbps_init(&xh), 0); a = xbps_array_create(); @@ -104,8 +104,8 @@ ATF_TC_BODY(find_all_orphans_test, tc) tcsdir = atf_tc_get_config_var(tc, "srcdir"); memset(&xh, 0, sizeof(xh)); - xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); + strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); + strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); ATF_REQUIRE_EQ(xbps_init(&xh), 0); pstr = xbps_string_create(); diff --git a/tests/xbps/libxbps/pkgdb/main.c b/tests/xbps/libxbps/pkgdb/main.c index 6e12dca94..df17d009f 100644 --- a/tests/xbps/libxbps/pkgdb/main.c +++ b/tests/xbps/libxbps/pkgdb/main.c @@ -42,8 +42,8 @@ ATF_TC_BODY(pkgdb_get_pkg_test, tc) tcsdir = atf_tc_get_config_var(tc, "srcdir"); memset(&xh, 0, sizeof(xh)); - xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); + strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); + strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); xh.flags = XBPS_FLAG_DEBUG; ATF_REQUIRE_EQ(xbps_init(&xh), 0); @@ -84,8 +84,8 @@ ATF_TC_BODY(pkgdb_get_virtualpkg_test, tc) tcsdir = atf_tc_get_config_var(tc, "srcdir"); memset(&xh, 0, sizeof(xh)); - xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); + strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); + strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); xh.flags = XBPS_FLAG_DEBUG; ATF_REQUIRE_EQ(xbps_init(&xh), 0); @@ -129,8 +129,8 @@ ATF_TC_BODY(pkgdb_get_pkg_revdeps_test, tc) tcsdir = atf_tc_get_config_var(tc, "srcdir"); memset(&xh, 0, sizeof(xh)); - xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); + strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); + strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); xh.flags = XBPS_FLAG_DEBUG; ATF_REQUIRE_EQ(xbps_init(&xh), 0); @@ -162,8 +162,8 @@ ATF_TC_BODY(pkgdb_pkg_reverts_test, tc) tcsdir = atf_tc_get_config_var(tc, "srcdir"); memset(&xh, 0, sizeof(xh)); - xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); - xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); + strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir)); + strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir)); xh.flags = XBPS_FLAG_DEBUG; ATF_REQUIRE_EQ(xbps_init(&xh), 0); diff --git a/tests/xbps/libxbps/util_path/main.c b/tests/xbps/libxbps/util_path/main.c index fbd14b9a6..ee4f0f828 100644 --- a/tests/xbps/libxbps/util_path/main.c +++ b/tests/xbps/libxbps/util_path/main.c @@ -41,7 +41,7 @@ ATF_TC_BODY(xbps_path_clean, tc) char buf[PATH_MAX]; ssize_t len; #define CLEAN(a, b) \ - xbps_strlcpy(buf, a, sizeof (buf)); \ + strlcpy(buf, a, sizeof (buf)); \ len = xbps_path_clean(buf); \ ATF_CHECK_EQ(len, sizeof (b)-1); \ ATF_CHECK_STREQ(buf, b) @@ -207,7 +207,7 @@ ATF_TC_BODY(xbps_path_append, tc) ssize_t len; /* empty prefix */ - xbps_strlcpy(buf, "fizz", sizeof buf); + strlcpy(buf, "fizz", sizeof buf); len = xbps_path_append(buf, sizeof buf, ""); ATF_CHECK_EQ(len, sizeof ("fizz") - 1); ATF_CHECK_STREQ(buf, "fizz"); @@ -219,69 +219,69 @@ ATF_TC_BODY(xbps_path_append, tc) ATF_CHECK_STREQ(buf, "buzz"); /* add slash */ - xbps_strlcpy(buf, "fizz", sizeof buf); + strlcpy(buf, "fizz", sizeof buf); len = xbps_path_append(buf, sizeof buf, "buzz"); ATF_CHECK_EQ(len, sizeof ("fizz/buzz") - 1); ATF_CHECK_STREQ(buf, "fizz/buzz"); /* already has slash in dst */ - xbps_strlcpy(buf, "fizz/", sizeof buf); + strlcpy(buf, "fizz/", sizeof buf); len = xbps_path_append(buf, sizeof buf, "buzz"); ATF_CHECK_EQ(len, sizeof ("fizz/buzz") - 1); ATF_CHECK_STREQ(buf, "fizz/buzz"); /* already has slash in suffix */ - xbps_strlcpy(buf, "fizz", sizeof buf); + strlcpy(buf, "fizz", sizeof buf); len = xbps_path_append(buf, sizeof buf, "/buzz"); ATF_CHECK_EQ(len, sizeof ("fizz/buzz") - 1); ATF_CHECK_STREQ(buf, "fizz/buzz"); /* slash in dst and suffix */ - xbps_strlcpy(buf, "fizz/", sizeof buf); + strlcpy(buf, "fizz/", sizeof buf); len = xbps_path_append(buf, sizeof buf, "/buzz"); ATF_CHECK_EQ(len, sizeof ("fizz/buzz") - 1); ATF_CHECK_STREQ(buf, "fizz/buzz"); - xbps_strlcpy(buf, "abcdefghijklmno", sizeof buf); + strlcpy(buf, "abcdefghijklmno", sizeof buf); len = xbps_path_append(buf, sizeof buf, "pqrstuvwxyz"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "abcdefghijklmn", sizeof buf); + strlcpy(buf, "abcdefghijklmn", sizeof buf); len = xbps_path_append(buf, sizeof buf, "opqrstuvwxyz"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "abcdefghijklm", sizeof buf); + strlcpy(buf, "abcdefghijklm", sizeof buf); len = xbps_path_append(buf, sizeof buf, "nopqrstuvwxyz"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "abcdefghijklmno/", sizeof buf); + strlcpy(buf, "abcdefghijklmno/", sizeof buf); len = xbps_path_append(buf, sizeof buf, "pqrstuvwxyz"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "abcdefghijklmn/", sizeof buf); + strlcpy(buf, "abcdefghijklmn/", sizeof buf); len = xbps_path_append(buf, sizeof buf, "opqrstuvwxyz"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "abcdefghijklm/", sizeof buf); + strlcpy(buf, "abcdefghijklm/", sizeof buf); len = xbps_path_append(buf, sizeof buf, "nopqrstuvwxyz"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "abcdefghijklmno", sizeof buf); + strlcpy(buf, "abcdefghijklmno", sizeof buf); len = xbps_path_append(buf, sizeof buf, ""); ATF_CHECK_EQ(len, sizeof ("abcdefghijklmno") - 1); ATF_CHECK_STREQ(buf, "abcdefghijklmno"); - xbps_strlcpy(buf, "abcdefghijklmn/", sizeof buf); + strlcpy(buf, "abcdefghijklmn/", sizeof buf); len = xbps_path_append(buf, sizeof buf, ""); ATF_CHECK_EQ(len, sizeof ("abcdefghijklmn/") - 1); ATF_CHECK_STREQ(buf, "abcdefghijklmn/"); - xbps_strlcpy(buf, "", sizeof buf); + strlcpy(buf, "", sizeof buf); len = xbps_path_append(buf, sizeof buf, "abcdefghijklmno"); ATF_CHECK_EQ(len, sizeof ("abcdefghijklmno") - 1); ATF_CHECK_STREQ(buf, "abcdefghijklmno"); - xbps_strlcpy(buf, "", sizeof buf); + strlcpy(buf, "", sizeof buf); len = xbps_path_append(buf, sizeof buf, "abcdefghijklmn/"); ATF_CHECK_EQ(len, sizeof ("abcdefghijklmn/") - 1); ATF_CHECK_STREQ(buf, "abcdefghijklmn/"); @@ -300,7 +300,7 @@ ATF_TC_BODY(xbps_path_prepend, tc) ssize_t len; /* empty prefix */ - xbps_strlcpy(buf, "buzz", sizeof buf); + strlcpy(buf, "buzz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, ""); ATF_CHECK_EQ(len, sizeof ("buzz") - 1); ATF_CHECK_STREQ(buf, "buzz"); @@ -312,76 +312,76 @@ ATF_TC_BODY(xbps_path_prepend, tc) ATF_CHECK_STREQ(buf, "buzz"); /* add slash */ - xbps_strlcpy(buf, "buzz", sizeof buf); + strlcpy(buf, "buzz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "fizz"); ATF_CHECK_EQ(len, sizeof ("fizz/buzz") - 1); ATF_CHECK_STREQ(buf, "fizz/buzz"); /* already has slash in dst */ - xbps_strlcpy(buf, "/buzz", sizeof buf); + strlcpy(buf, "/buzz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "fizz"); ATF_CHECK_EQ(len, sizeof ("fizz/buzz") - 1); ATF_CHECK_STREQ(buf, "fizz/buzz"); /* already has slash in prefix */ - xbps_strlcpy(buf, "buzz", sizeof buf); + strlcpy(buf, "buzz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "fizz/"); ATF_CHECK_EQ(len, sizeof ("fizz/buzz") - 1); ATF_CHECK_STREQ(buf, "fizz/buzz"); /* slash in dst and prefix */ - xbps_strlcpy(buf, "/buzz", sizeof buf); + strlcpy(buf, "/buzz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "fizz/"); ATF_CHECK_EQ(len, sizeof ("fizz/buzz") - 1); ATF_CHECK_STREQ(buf, "fizz/buzz"); /* check truncation no slashes */ - xbps_strlcpy(buf, "bar/buzz", sizeof buf); + strlcpy(buf, "bar/buzz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "fizz/foo"); ATF_CHECK_EQ(len, -1); /* check truncation slash in dst*/ - xbps_strlcpy(buf, "/bar/buzz", sizeof buf); + strlcpy(buf, "/bar/buzz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "fizz/foo"); ATF_CHECK_EQ(len, -1); /* check truncation slash in prefix */ - xbps_strlcpy(buf, "bar/buzz", sizeof buf); + strlcpy(buf, "bar/buzz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "fizz/foo/"); ATF_CHECK_EQ(len, -1); /* check truncation slash in both */ - xbps_strlcpy(buf, "/bar/buzz", sizeof buf); + strlcpy(buf, "/bar/buzz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "fizz/foo/"); ATF_CHECK_EQ(len, -1); /* check truncation */ - xbps_strlcpy(buf, "pqrstuvwxyz", sizeof buf); + strlcpy(buf, "pqrstuvwxyz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "abcdefghijklmno"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "/opqrstuvwxyz", sizeof buf); + strlcpy(buf, "/opqrstuvwxyz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "abcdefghijklmn/"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "/nopqrstuvwxyz", sizeof buf); + strlcpy(buf, "/nopqrstuvwxyz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "abcdefghijklm/"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "opqrstuvwxyz", sizeof buf); + strlcpy(buf, "opqrstuvwxyz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "abcdefghijklmn"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "nopqrstuvwxyz", sizeof buf); + strlcpy(buf, "nopqrstuvwxyz", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "abcdefghijklm"); ATF_CHECK_EQ(len, -1); - xbps_strlcpy(buf, "", sizeof buf); + strlcpy(buf, "", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "abcdefghijklmno"); ATF_CHECK_EQ(len, sizeof ("abcdefghijklmno") - 1); ATF_CHECK_STREQ(buf, "abcdefghijklmno"); - xbps_strlcpy(buf, "", sizeof buf); + strlcpy(buf, "", sizeof buf); len = xbps_path_prepend(buf, sizeof buf, "abcdefghijklm/"); ATF_CHECK_EQ(len, sizeof ("abcdefghijklm/") - 1); ATF_CHECK_STREQ(buf, "abcdefghijklm/");