Added a configure script to emulate GNU autoconf and related changes.
Changes included in this set: * Added strlcat() and strlcpy() from OpenBSD, always use them if the system does not have them built in. * Changed an array of PATH_MAX size allocated in the stack, to a dynamically allocated buffer from heap. This should reduce memory usage a bit. * Simplify code that implemented a homegrown realpath(3) implementation, simply use realpath(3). * If compiler supports -fstack-protector, build all code with -D_FORTIFY_SOURCE=2 and --param ssp-buffer-size=1 so that all buffers are protected.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
include ../vars.mk
|
||||
-include ../config.mk
|
||||
|
||||
SUBDIRS = xbps-uhelper
|
||||
SUBDIRS += xbps-repo
|
||||
|
@@ -1,5 +1,5 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/vars.mk
|
||||
-include $(TOPDIR)/config.mk
|
||||
|
||||
BIN = xbps-bin
|
||||
OBJS = check.o install.o main.o remove.o show-deps.o
|
||||
|
@@ -1,5 +1,5 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/vars.mk
|
||||
-include $(TOPDIR)/config.mk
|
||||
|
||||
BIN = xbps-repo
|
||||
OBJS = main.o util.o index.o repository.o
|
||||
|
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <xbps_api.h>
|
||||
#include "defs.h"
|
||||
#include "config.h"
|
||||
|
||||
struct repoinfo {
|
||||
char *pkgidxver;
|
||||
@@ -98,54 +99,13 @@ out:
|
||||
return rpi;
|
||||
}
|
||||
|
||||
static bool
|
||||
sanitize_url(char *buf, const char *path)
|
||||
{
|
||||
char *dirnp, *basenp, *dir, *base, *tmp;
|
||||
bool rv = false;
|
||||
|
||||
dir = strdup(path);
|
||||
if (dir == NULL)
|
||||
return false;
|
||||
|
||||
base = strdup(path);
|
||||
if (base == NULL) {
|
||||
free(dir);
|
||||
return false;
|
||||
}
|
||||
|
||||
dirnp = dirname(dir);
|
||||
if (strcmp(dirnp, ".") == 0)
|
||||
goto out;
|
||||
|
||||
basenp = basename(base);
|
||||
if (strcmp(basenp, base) == 0)
|
||||
goto out;
|
||||
|
||||
tmp = strncpy(buf, dirnp, PATH_MAX - 1);
|
||||
if (sizeof(*tmp) >= PATH_MAX)
|
||||
goto out;
|
||||
|
||||
buf[strlen(buf) + 1] = '\0';
|
||||
if (strcmp(dirnp, "/"))
|
||||
strncat(buf, "/", 1);
|
||||
strncat(buf, basenp, PATH_MAX - strlen(buf) - 1);
|
||||
rv = true;
|
||||
|
||||
out:
|
||||
free(dir);
|
||||
free(base);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
unregister_repository(const char *uri)
|
||||
{
|
||||
char idxstr[PATH_MAX];
|
||||
int rv = 0;
|
||||
|
||||
if (!sanitize_url(idxstr, uri))
|
||||
if (!realpath(uri, idxstr))
|
||||
return errno;
|
||||
|
||||
if ((rv = xbps_repository_unregister(idxstr)) != 0) {
|
||||
@@ -168,7 +128,7 @@ register_repository(const char *uri)
|
||||
int rv = 0;
|
||||
|
||||
if (xbps_check_is_repo_string_remote(uri)) {
|
||||
if (!sanitize_url(idxstr, uri))
|
||||
if (!realpath(uri, idxstr))
|
||||
return errno;
|
||||
|
||||
printf("Fetching remote package index at %s...\n", uri);
|
||||
@@ -186,7 +146,7 @@ register_repository(const char *uri)
|
||||
|
||||
plist = xbps_get_pkg_index_plist(idxstr);
|
||||
} else {
|
||||
if (!sanitize_url(idxstr, uri))
|
||||
if (!realpath(uri, idxstr))
|
||||
return errno;
|
||||
|
||||
/*
|
||||
@@ -226,7 +186,7 @@ register_repository(const char *uri)
|
||||
}
|
||||
|
||||
printf("Added package index at %s (v%s) with %ju packages.\n",
|
||||
uri, rpi->pkgidxver, rpi->totalpkgs);
|
||||
idxstr, rpi->pkgidxver, rpi->totalpkgs);
|
||||
|
||||
out:
|
||||
if (rpi != NULL)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/vars.mk
|
||||
-include $(TOPDIR)/config.mk
|
||||
|
||||
BIN = xbps-uhelper
|
||||
|
||||
|
@@ -102,9 +102,9 @@ main(int argc, char **argv)
|
||||
{
|
||||
prop_dictionary_t dict;
|
||||
const char *version;
|
||||
char *plist, *pkgname, *pkgver, *in_chroot_env, *root = "";
|
||||
char *plist, *pkgname, *pkgver, *in_chroot_env, *root = "", *hash;
|
||||
bool in_chroot = false;
|
||||
int c, rv = 0;
|
||||
int i, c, rv = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "Var:")) != -1) {
|
||||
switch (c) {
|
||||
@@ -299,9 +299,6 @@ main(int argc, char **argv)
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
char *hash;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
hash = xbps_get_file_hash(argv[i]);
|
||||
if (hash == NULL) {
|
||||
@@ -320,7 +317,6 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
|
||||
xbps_fetch_set_cache_connection(0, 0);
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
rv = xbps_fetch_file(argv[i], ".", false, "v");
|
||||
|
Reference in New Issue
Block a user