From 2434b90d6eed3e9b94e369f1a33ed88a744d6728 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 17 Apr 2016 20:17:37 +0200 Subject: [PATCH] libxbps: use xbps_strlc{at,py} everywhere. --- lib/download.c | 6 ++---- lib/external/dewey.c | 2 +- lib/initend.c | 10 ++++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/download.c b/lib/download.c index 7dc67295..cea15a1c 100644 --- a/lib/download.c +++ b/lib/download.c @@ -36,9 +36,7 @@ #include #include #include -#define _BSD_SOURCE /* musl has strlcpy if _{BSD,GNU}_SOURCE is defined */ #include -#undef _BSD_SOURCE #include #include #include @@ -118,7 +116,7 @@ xbps_fetch_file_dest(struct xbps_handle *xhp, const char *uri, const char *filen memset(&fetch_flags, 0, sizeof(fetch_flags)); if (flags != NULL) - strlcpy(fetch_flags, flags, 7); + xbps_strlcpy(fetch_flags, flags, 7); tempfile = xbps_xasprintf("%s.part", filename); /* @@ -141,7 +139,7 @@ xbps_fetch_file_dest(struct xbps_handle *xhp, const char *uri, const char *filen if (stat(filename, &st) == 0) { refetch = true; url->last_modified = st.st_mtime; - strlcat(fetch_flags, "i", sizeof(fetch_flags)); + xbps_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 f6502d42..6d93a137 100644 --- a/lib/external/dewey.c +++ b/lib/external/dewey.c @@ -330,7 +330,7 @@ dewey_match(const char *pattern, const char *pkg) if (sep2) { char ver[PKG_PATTERN_MAX]; - strlcpy(ver, sep, MIN((ssize_t)sizeof(ver), sep2-sep+1)); + xbps_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 15d7b471..3a31fcfc 100644 --- a/lib/initend.c +++ b/lib/initend.c @@ -31,9 +31,7 @@ #endif #include #include -#define _BSD_SOURCE /* required by strlcpy with musl */ #include -#undef _BSD_SOURCE #include #include #include @@ -124,7 +122,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); - strlcpy(p, globbuf.gl_pathv[i] + strlen(xhp->rootdir), len); + xbps_strlcpy(p, globbuf.gl_pathv[i] + strlen(xhp->rootdir), len); xbps_array_add_cstring(xhp->preserved_files, p); xbps_dbg_printf(xhp, "Added preserved file: %s (expanded from %s)\n", p, file); free(p); @@ -286,7 +284,7 @@ parse_file(struct xbps_handle *xhp, const char *cwd, const char *path, bool nest continue; /* cwd to the dir containing the config file */ - strlcpy(tmppath, path, sizeof(tmppath)); + xbps_strlcpy(tmppath, path, sizeof(tmppath)); cfcwd = dirname(tmppath); if (chdir(cfcwd) == -1) { rv = errno; @@ -438,10 +436,10 @@ xbps_init(struct xbps_handle *xhp) xhp->target_arch = getenv("XBPS_TARGET_ARCH"); if ((native_arch = getenv("XBPS_ARCH")) != NULL) { - strlcpy(xhp->native_arch, native_arch, sizeof(xhp->native_arch)); + xbps_strlcpy(xhp->native_arch, native_arch, sizeof(xhp->native_arch)); } else { uname(&un); - strlcpy(xhp->native_arch, un.machine, sizeof(xhp->native_arch)); + xbps_strlcpy(xhp->native_arch, un.machine, sizeof(xhp->native_arch)); } assert(xhp->native_arch);