Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge remote-tracking branch 'upstream/master'
Shawn Webb committed 2 years ago
commit 0caa2300bf794a28082a4e30d080b44219e08af3
parent d66462e
4 files changed +30 -46
modified README.md
@@ -1,17 +1,6 @@
pkg - a binary package manager for FreeBSD
==========================================

-
Known to fully work on (official package manager):
-

-
- FreeBSD
-
- DragonflyBSD
-

-
Known to work on (has been ported to):
-

-
- Linux
-
- NetBSD/EdgeBSD
-
- OSX
-

Table of Contents:
------------------

@@ -37,11 +26,10 @@ Table of Contents:
* [Creating a package repository](#pkgcreate)
* [Additional resources](#resources)

-
Cirrus CI: (Linux, OSX, FreeBSD):
-
[![Build Status](https://api.cirrus-ci.com/github/freebsd/pkg.svg)](https://cirrus-ci.com/github/freebsd/pkg)
SourceHut CI:
[![builds.sr.ht status](https://builds.sr.ht/~bapt/pkg/commits/master/freebsd.svg)](https://builds.sr.ht/~bapt/pkg/commits/master/freebsd?)
[![builds.sr.ht status](https://builds.sr.ht/~bapt/pkg/commits/master/alpine.svg)](https://builds.sr.ht/~bapt/pkg/commits/master/alpine?)
+
[![builds.sr.ht status](https://builds.sr.ht/~bapt/pkg/commits/master/alpine.svg)](https://builds.sr.ht/~bapt/pkg/commits/master/debian?)

<a name="libpkg"></a>
### libpkg
modified external/blake2/blake2-impl.h
@@ -18,19 +18,7 @@
#include <stdint.h>
#include <string.h>

-
#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
-
  #if   defined(_MSC_VER)
-
    #define BLAKE2_INLINE __inline
-
  #elif defined(__GNUC__)
-
    #define BLAKE2_INLINE __inline__
-
  #else
-
    #define BLAKE2_INLINE
-
  #endif
-
#else
-
  #define BLAKE2_INLINE inline
-
#endif
-

-
static BLAKE2_INLINE uint32_t load32( const void *src )
+
static inline uint32_t load32( const void *src )
{
#if defined(NATIVE_LITTLE_ENDIAN)
  uint32_t w;
@@ -45,7 +33,7 @@ static BLAKE2_INLINE uint32_t load32( const void *src )
#endif
}

-
static BLAKE2_INLINE uint64_t load64( const void *src )
+
static inline uint64_t load64( const void *src )
{
#if defined(NATIVE_LITTLE_ENDIAN)
  uint64_t w;
@@ -64,7 +52,7 @@ static BLAKE2_INLINE uint64_t load64( const void *src )
#endif
}

-
static BLAKE2_INLINE uint16_t load16( const void *src )
+
static inline uint16_t load16( const void *src )
{
#if defined(NATIVE_LITTLE_ENDIAN)
  uint16_t w;
@@ -77,7 +65,7 @@ static BLAKE2_INLINE uint16_t load16( const void *src )
#endif
}

-
static BLAKE2_INLINE void store16( void *dst, uint16_t w )
+
static inline void store16( void *dst, uint16_t w )
{
#if defined(NATIVE_LITTLE_ENDIAN)
  memcpy(dst, &w, sizeof w);
@@ -88,7 +76,7 @@ static BLAKE2_INLINE void store16( void *dst, uint16_t w )
#endif
}

-
static BLAKE2_INLINE void store32( void *dst, uint32_t w )
+
static inline void store32( void *dst, uint32_t w )
{
#if defined(NATIVE_LITTLE_ENDIAN)
  memcpy(dst, &w, sizeof w);
@@ -101,7 +89,7 @@ static BLAKE2_INLINE void store32( void *dst, uint32_t w )
#endif
}

-
static BLAKE2_INLINE void store64( void *dst, uint64_t w )
+
static inline void store64( void *dst, uint64_t w )
{
#if defined(NATIVE_LITTLE_ENDIAN)
  memcpy(dst, &w, sizeof w);
@@ -118,7 +106,7 @@ static BLAKE2_INLINE void store64( void *dst, uint64_t w )
#endif
}

-
static BLAKE2_INLINE uint64_t load48( const void *src )
+
static inline uint64_t load48( const void *src )
{
  const uint8_t *p = ( const uint8_t * )src;
  return (( uint64_t )( p[0] ) <<  0) |
@@ -129,7 +117,7 @@ static BLAKE2_INLINE uint64_t load48( const void *src )
         (( uint64_t )( p[5] ) << 40) ;
}

-
static BLAKE2_INLINE void store48( void *dst, uint64_t w )
+
static inline void store48( void *dst, uint64_t w )
{
  uint8_t *p = ( uint8_t * )dst;
  p[0] = (uint8_t)(w >>  0);
@@ -140,18 +128,18 @@ static BLAKE2_INLINE void store48( void *dst, uint64_t w )
  p[5] = (uint8_t)(w >> 40);
}

-
static BLAKE2_INLINE uint32_t rotr32( const uint32_t w, const unsigned c )
+
static inline uint32_t rotr32( const uint32_t w, const unsigned c )
{
  return ( w >> c ) | ( w << ( 32 - c ) );
}

-
static BLAKE2_INLINE uint64_t rotr64( const uint64_t w, const unsigned c )
+
static inline uint64_t rotr64( const uint64_t w, const unsigned c )
{
  return ( w >> c ) | ( w << ( 64 - c ) );
}

/* prevents compiler optimizing out memset() */
-
static BLAKE2_INLINE void secure_zero_memory(void *v, size_t n)
+
static inline void secure_zero_memory(void *v, size_t n)
{
  static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
  memset_v(v, 0, n);
modified libpkg/elfhints.c
@@ -66,8 +66,11 @@ static void write_elf_hints(const char *);

static const char	*dirs[MAXDIRS];
static int		 ndirs;
+
static int		 is_be;
int			 insecure;

+
#define COND_SWAP(n) (is_be ? be32toh(n) : le32toh(n))
+

/* Known shlibs on the standard system search path.  Persistent,
   common to all applications */
static pkghash *shlibs = NULL;
@@ -451,14 +454,15 @@ read_elf_hints(const char *hintsfile, int must_exist)
	close(fd);

	hdr = (struct elfhints_hdr *)mapbase;
-
	if (hdr->magic != ELFHINTS_MAGIC)
+
	is_be = be32toh(hdr->magic) == ELFHINTS_MAGIC;
+
	if (COND_SWAP(hdr->magic) != ELFHINTS_MAGIC)
		errx(1, "\"%s\": invalid file format", hintsfile);
-
	if (hdr->version != 1)
+
	if (COND_SWAP(hdr->version) != 1)
		errx(1, "\"%s\": unrecognized file version (%d)", hintsfile,
-
		    hdr->version);
+
		    COND_SWAP(hdr->version));

-
	strtab = (char *)mapbase + hdr->strtab;
-
	dirlist = strtab + hdr->dirlist;
+
	strtab = (char *)mapbase + COND_SWAP(hdr->strtab);
+
	dirlist = strtab + COND_SWAP(hdr->dirlist);

	if (*dirlist != '\0')
		while ((p = strsep(&dirlist, ":")) != NULL)
@@ -472,6 +476,9 @@ update_elf_hints(const char *hintsfile, int argc, char **argv, int merge)

	if (merge)
		read_elf_hints(hintsfile, 0);
+
	else
+
		// remove when FreeBSD switches to LE for all architectures
+
		is_be = be32toh(1) == 1;
	for (i = 0;  i < argc;  i++) {
		struct stat	s;

@@ -502,9 +509,9 @@ write_elf_hints(const char *hintsfile)
	if ((fp = fdopen(fd, "wb")) == NULL)
		err(1, "fdopen(%s)", tempname);

-
	hdr.magic = ELFHINTS_MAGIC;
-
	hdr.version = 1;
-
	hdr.strtab = sizeof hdr;
+
	hdr.magic = COND_SWAP(ELFHINTS_MAGIC);
+
	hdr.version = COND_SWAP(1);
+
	hdr.strtab = COND_SWAP(sizeof hdr);
	hdr.strsize = 0;
	hdr.dirlist = 0;
	memset(hdr.spare, 0, sizeof hdr.spare);
@@ -515,8 +522,9 @@ write_elf_hints(const char *hintsfile)
		for (i = 1;  i < ndirs;  i++)
			hdr.strsize += 1 + strlen(dirs[i]);
	}
-
	hdr.dirlistlen = hdr.strsize;
+
	hdr.dirlistlen = COND_SWAP(hdr.strsize);
	hdr.strsize++;	/* For the null terminator */
+
	hdr.strsize = COND_SWAP(hdr.strsize);

	/* Write the header. */
	if (fwrite(&hdr, 1, sizeof hdr, fp) != sizeof hdr)
modified libpkg/pkgdb_query.c
@@ -393,7 +393,7 @@ pkgdb_repo_query_cond(struct pkgdb *db, const char *cond, const char *pattern, m

	tll_foreach(db->repos, cur) {
		if (repo == NULL || strcasecmp(cur->item->name, repo) == 0) {
-
			if (*pattern == '@')
+
			if (pattern != NULL && *pattern == '@')
				rit = cur->item->ops->groupquery(cur->item, pattern + 1, match);
			else
				rit = cur->item->ops->query(cur->item, cond, pattern, match);