summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libarchive/tests/Makefile12
-rw-r--r--lib/libbsnmp/libbsnmp/Makefile97
-rw-r--r--lib/libc/gen/jrand48.c5
-rw-r--r--lib/libc/gen/mrand48.c6
-rw-r--r--lib/libc/net/getaddrinfo.c12
-rw-r--r--lib/libkvm/kvm_proc.c2
-rw-r--r--lib/libusb/libusb20_ugen20.c4
-rw-r--r--lib/libutil/gr_util.c39
-rw-r--r--lib/libutil/pw_util.c39
9 files changed, 171 insertions, 45 deletions
diff --git a/lib/libarchive/tests/Makefile b/lib/libarchive/tests/Makefile
index f0ede5f..58c642e 100644
--- a/lib/libarchive/tests/Makefile
+++ b/lib/libarchive/tests/Makefile
@@ -11,7 +11,7 @@ BINDIR= ${TESTSDIR}
PROGS+= libarchive_test
-CFLAGS+= -I${.CURDIR:H} -I${.OBJDIR}
+CFLAGS+= -I${.CURDIR} -I${.CURDIR:H} -I${.OBJDIR}
CFLAGS+= -I${LIBARCHIVEDIR}/libarchive -I${LIBARCHIVEDIR}/test_utils
CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
@@ -70,8 +70,11 @@ TESTS_SRCS= \
test_compat_lzop.c \
test_compat_mac.c \
test_compat_pax_libarchive_2x.c \
+ test_compat_perl_archive_tar.c \
+ test_compat_plexus_archiver_tar.c \
test_compat_solaris_tar_acl.c \
test_compat_solaris_pax_sparse.c \
+ test_compat_star_acl_posix1e.c \
test_compat_tar_hardlink.c \
test_compat_uudecode.c \
test_compat_uudecode_large.c \
@@ -178,6 +181,7 @@ TESTS_SRCS= \
test_read_format_zip_encryption_partially.c \
test_read_format_zip_filename.c \
test_read_format_zip_high_compression.c \
+ test_read_format_zip_jar.c \
test_read_format_zip_mac_metadata.c \
test_read_format_zip_malformed.c \
test_read_format_zip_msdos.c \
@@ -321,6 +325,7 @@ FILES+= test_compat_bzip2_1.tbz.uu
FILES+= test_compat_bzip2_2.tbz.uu
FILES+= test_compat_cpio_1.cpio.uu
FILES+= test_compat_gtar_1.tar.uu
+FILES+= test_compat_gtar_2.tar.uu
FILES+= test_compat_gzip_1.tgz.uu
FILES+= test_compat_lz4_1.tar.lz4.uu
FILES+= test_compat_lz4_2.tar.lz4.uu
@@ -346,9 +351,12 @@ FILES+= test_compat_lzop_3.tar.lzo.uu
FILES+= test_compat_mac-1.tar.Z.uu
FILES+= test_compat_mac-2.tar.Z.uu
FILES+= test_compat_pax_libarchive_2x.tar.Z.uu
+FILES+= test_compat_perl_archive_tar.tar.uu
+FILES+= test_compat_plexus_archiver_tar.tar.uu
FILES+= test_compat_solaris_pax_sparse_1.pax.Z.uu
FILES+= test_compat_solaris_pax_sparse_2.pax.Z.uu
FILES+= test_compat_solaris_tar_acl.tar.uu
+FILES+= test_compat_star_acl_posix1e.tar.uu
FILES+= test_compat_tar_hardlink_1.tar.uu
FILES+= test_compat_uudecode_large.tar.Z.uu
FILES+= test_compat_xz_1.txz.uu
@@ -490,6 +498,7 @@ FILES+= test_read_format_rar_sfx.exe.uu
FILES+= test_read_format_rar_subblock.rar.uu
FILES+= test_read_format_rar_unicode.rar.uu
FILES+= test_read_format_rar_windows.rar.uu
+FILES+= test_read_format_raw.bufr.uu
FILES+= test_read_format_raw.data.Z.uu
FILES+= test_read_format_raw.data.uu
FILES+= test_read_format_tar_concatenated.tar.uu
@@ -513,6 +522,7 @@ FILES+= test_read_format_zip_filename_utf8_jp.zip.uu
FILES+= test_read_format_zip_filename_utf8_ru.zip.uu
FILES+= test_read_format_zip_filename_utf8_ru2.zip.uu
FILES+= test_read_format_zip_high_compression.zip.uu
+FILES+= test_read_format_zip_jar.jar.uu
FILES+= test_read_format_zip_length_at_end.zip.uu
FILES+= test_read_format_zip_mac_metadata.zip.uu
FILES+= test_read_format_zip_malformed1.zip.uu
diff --git a/lib/libbsnmp/libbsnmp/Makefile b/lib/libbsnmp/libbsnmp/Makefile
index 20015b9..a756f90 100644
--- a/lib/libbsnmp/libbsnmp/Makefile
+++ b/lib/libbsnmp/libbsnmp/Makefile
@@ -20,7 +20,100 @@ LDADD+= -lcrypto
.endif
SRCS= asn1.c snmp.c snmpagent.c snmpclient.c snmpcrypto.c support.c
-INCS= asn1.h snmp.h snmpagent.h snmpclient.h
-MAN= asn1.3 bsnmplib.3 bsnmpclient.3 bsnmpagent.3
+INCS= asn1.h snmp.h snmpagent.h snmpclient.h
+MAN= asn1.3 bsnmpagent.3 bsnmpclient.3 bsnmplib.3
+
+MLINKS+= asn1.3 asn_append_oid.3
+MLINKS+= asn1.3 asn_commit_header.3
+MLINKS+= asn1.3 asn_compare_oid.3
+MLINKS+= asn1.3 asn_get_counter64_raw.3
+MLINKS+= asn1.3 asn_get_header.3
+MLINKS+= asn1.3 asn_get_integer.3
+MLINKS+= asn1.3 asn_get_integer_raw.3
+MLINKS+= asn1.3 asn_get_ipaddress.3
+MLINKS+= asn1.3 asn_get_ipaddress_raw.3
+MLINKS+= asn1.3 asn_get_null.3
+MLINKS+= asn1.3 asn_get_null_raw.3
+MLINKS+= asn1.3 asn_get_objid.3
+MLINKS+= asn1.3 asn_get_objid_raw.3
+MLINKS+= asn1.3 asn_get_octetstring.3
+MLINKS+= asn1.3 asn_get_octetstring_raw.3
+MLINKS+= asn1.3 asn_get_sequence.3
+MLINKS+= asn1.3 asn_get_timeticks.3
+MLINKS+= asn1.3 asn_get_uint32_raw.3
+MLINKS+= asn1.3 asn_is_suboid.3
+MLINKS+= asn1.3 asn_oid2str.3
+MLINKS+= asn1.3 asn_oid2str_r.3
+MLINKS+= asn1.3 asn_put_counter64.3
+MLINKS+= asn1.3 asn_put_exception.3
+MLINKS+= asn1.3 asn_put_header.3
+MLINKS+= asn1.3 asn_put_integer.3
+MLINKS+= asn1.3 asn_put_ipaddress.3
+MLINKS+= asn1.3 asn_put_null.3
+MLINKS+= asn1.3 asn_put_objid.3
+MLINKS+= asn1.3 asn_put_octetstring.3
+MLINKS+= asn1.3 asn_put_temp_header.3
+MLINKS+= asn1.3 asn_put_timeticks.3
+MLINKS+= asn1.3 asn_put_uint32.3
+MLINKS+= asn1.3 asn_skip.3
+MLINKS+= asn1.3 asn_slice_oid.3
+
+MLINKS+= bsnmpagent.3 snmp_debug.3
+MLINKS+= bsnmpagent.3 snmp_dep_commit.3
+MLINKS+= bsnmpagent.3 snmp_dep_finish.3
+MLINKS+= bsnmpagent.3 snmp_dep_lookup.3
+MLINKS+= bsnmpagent.3 snmp_dep_rollback.3
+MLINKS+= bsnmpagent.3 snmp_depop_t.3
+MLINKS+= bsnmpagent.3 snmp_get.3
+MLINKS+= bsnmpagent.3 snmp_getbulk.3
+MLINKS+= bsnmpagent.3 snmp_getnext.3
+MLINKS+= bsnmpagent.3 snmp_init_context.3
+MLINKS+= bsnmpagent.3 snmp_make_errresp.3
+MLINKS+= bsnmpagent.3 snmp_op_t.3
+MLINKS+= bsnmpagent.3 snmp_set.3
+MLINKS+= bsnmpagent.3 snmp_trace.3
+MLINKS+= bsnmpagent.3 tree.3
+MLINKS+= bsnmpagent.3 tree_size.3
+
+MLINKS+= bsnmpclient.3 snmp_add_binding.3
+MLINKS+= bsnmpclient.3 snmp_client.3
+MLINKS+= bsnmpclient.3 snmp_client_init.3
+MLINKS+= bsnmpclient.3 snmp_client_set_host.3
+MLINKS+= bsnmpclient.3 snmp_client_set_port.3
+MLINKS+= bsnmpclient.3 snmp_close.3
+MLINKS+= bsnmpclient.3 snmp_dialog.3
+MLINKS+= bsnmpclient.3 snmp_discover_engine.3
+MLINKS+= bsnmpclient.3 snmp_oid_append.3
+MLINKS+= bsnmpclient.3 snmp_open.3
+MLINKS+= bsnmpclient.3 snmp_parse_server.3
+MLINKS+= bsnmpclient.3 snmp_pdu_check.3
+MLINKS+= bsnmpclient.3 snmp_pdu_create.3
+MLINKS+= bsnmpclient.3 snmp_pdu_send.3
+MLINKS+= bsnmpclient.3 snmp_receive.3
+MLINKS+= bsnmpclient.3 snmp_send_cb_f.3
+MLINKS+= bsnmpclient.3 snmp_table_cb_f.3
+MLINKS+= bsnmpclient.3 snmp_table_fetch.3
+MLINKS+= bsnmpclient.3 snmp_table_fetch_async.3
+MLINKS+= bsnmpclient.3 snmp_timeout_cb_f.3
+MLINKS+= bsnmpclient.3 snmp_timeout_start_f.3
+MLINKS+= bsnmpclient.3 snmp_timeout_stop_f.3
+
+MLINKS+= bsnmplib.3 TRUTH_GET.3
+MLINKS+= bsnmplib.3 TRUTH_MK.3
+MLINKS+= bsnmplib.3 TRUTH_OK.3
+MLINKS+= bsnmplib.3 snmp_calc_keychange.3
+MLINKS+= bsnmplib.3 snmp_get_local_keys.3
+MLINKS+= bsnmplib.3 snmp_passwd_to_keys.3
+MLINKS+= bsnmplib.3 snmp_pdu_decode.3
+MLINKS+= bsnmplib.3 snmp_pdu_decode_header.3
+MLINKS+= bsnmplib.3 snmp_pdu_decode_scoped.3
+MLINKS+= bsnmplib.3 snmp_pdu_decode_secmode.3
+MLINKS+= bsnmplib.3 snmp_pdu_dump.3
+MLINKS+= bsnmplib.3 snmp_pdu_encode.3
+MLINKS+= bsnmplib.3 snmp_pdu_free.3
+MLINKS+= bsnmplib.3 snmp_pdu_init_secparams.3
+MLINKS+= bsnmplib.3 snmp_value_copy.3
+MLINKS+= bsnmplib.3 snmp_value_free.3
+MLINKS+= bsnmplib.3 snmp_value_parse.3
.include <bsd.lib.mk>
diff --git a/lib/libc/gen/jrand48.c b/lib/libc/gen/jrand48.c
index 1707620..5aab1e1 100644
--- a/lib/libc/gen/jrand48.c
+++ b/lib/libc/gen/jrand48.c
@@ -14,11 +14,14 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <stdint.h>
+
#include "rand48.h"
long
jrand48(unsigned short xseed[3])
{
+
_dorand48(xseed);
- return ((long) xseed[2] << 16) + (long) xseed[1];
+ return ((int32_t)(((uint32_t)xseed[2] << 16) | (uint32_t)xseed[1]));
}
diff --git a/lib/libc/gen/mrand48.c b/lib/libc/gen/mrand48.c
index ef20fb87b..795a858 100644
--- a/lib/libc/gen/mrand48.c
+++ b/lib/libc/gen/mrand48.c
@@ -14,6 +14,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <stdint.h>
+
#include "rand48.h"
extern unsigned short _rand48_seed[3];
@@ -21,6 +23,8 @@ extern unsigned short _rand48_seed[3];
long
mrand48(void)
{
+
_dorand48(_rand48_seed);
- return ((long) _rand48_seed[2] << 16) + (long) _rand48_seed[1];
+ return ((int32_t)(((uint32_t)_rand48_seed[2] << 16) |
+ (uint32_t)_rand48_seed[1]));
}
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index ec22570..163241b 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -673,9 +673,8 @@ reorder(struct addrinfo *sentinel)
return(n);
/* allocate a temporary array for sort and initialization of it. */
- if ((aio = malloc(sizeof(*aio) * n)) == NULL)
+ if ((aio = calloc(n, sizeof(*aio))) == NULL)
return(n); /* give up reordering */
- memset(aio, 0, sizeof(*aio) * n);
/* retrieve address selection policy from the kernel */
TAILQ_INIT(&policyhead);
@@ -1454,9 +1453,8 @@ copy_ai(const struct addrinfo *pai)
size_t l;
l = sizeof(*ai) + pai->ai_addrlen;
- if ((ai = (struct addrinfo *)malloc(l)) == NULL)
+ if ((ai = calloc(1, l)) == NULL)
return NULL;
- memset(ai, 0, l);
memcpy(ai, pai, sizeof(*ai));
ai->ai_addr = (struct sockaddr *)(void *)(ai + 1);
memcpy(ai->ai_addr, pai->ai_addr, pai->ai_addrlen);
@@ -1876,8 +1874,7 @@ addrinfo_unmarshal_func(char *buffer, size_t buffer_size, void *retval,
size = new_ai.ai_addrlen + sizeof(struct addrinfo) +
_ALIGNBYTES;
- sentinel = (struct addrinfo *)malloc(size);
- memset(sentinel, 0, size);
+ sentinel = calloc(1, size);
memcpy(sentinel, &new_ai, sizeof(struct addrinfo));
sentinel->ai_addr = (struct sockaddr *)_ALIGN((char *)sentinel +
@@ -1890,8 +1887,7 @@ addrinfo_unmarshal_func(char *buffer, size_t buffer_size, void *retval,
memcpy(&size, p, sizeof(size_t));
p += sizeof(size_t);
- sentinel->ai_canonname = (char *)malloc(size + 1);
- memset(sentinel->ai_canonname, 0, size + 1);
+ sentinel->ai_canonname = calloc(1, size + 1);
memcpy(sentinel->ai_canonname, p, size);
p += size;
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c
index f8e152e..ed34a9c 100644
--- a/lib/libkvm/kvm_proc.c
+++ b/lib/libkvm/kvm_proc.c
@@ -424,8 +424,6 @@ nopgrp:
kp->ki_pri.pri_native = mtd.td_base_pri;
kp->ki_lastcpu = mtd.td_lastcpu;
kp->ki_wchan = mtd.td_wchan;
- if (mtd.td_name[0] != 0)
- strlcpy(kp->ki_tdname, mtd.td_name, MAXCOMLEN);
kp->ki_oncpu = mtd.td_oncpu;
if (mtd.td_name[0] != '\0')
strlcpy(kp->ki_tdname, mtd.td_name, sizeof(kp->ki_tdname));
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c
index e40bc07..be2acee 100644
--- a/lib/libusb/libusb20_ugen20.c
+++ b/lib/libusb/libusb20_ugen20.c
@@ -214,8 +214,8 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
snprintf(pdev->usb_desc, sizeof(pdev->usb_desc),
USB_GENERIC_NAME "%u.%u: <%s %s> at usbus%u", pdev->bus_number,
- pdev->device_address, devinfo.udi_product,
- devinfo.udi_vendor, pdev->bus_number);
+ pdev->device_address, devinfo.udi_vendor,
+ devinfo.udi_product, pdev->bus_number);
error = 0;
done:
diff --git a/lib/libutil/gr_util.c b/lib/libutil/gr_util.c
index 80d9ee6..6979ba0 100644
--- a/lib/libutil/gr_util.c
+++ b/lib/libutil/gr_util.c
@@ -141,7 +141,7 @@ gr_tmp(int mfd)
errno = ENAMETOOLONG;
return (-1);
}
- if ((tfd = mkostemp(tempname, O_SYNC)) == -1)
+ if ((tfd = mkostemp(tempname, 0)) == -1)
return (-1);
if (mfd != -1) {
while ((nr = read(mfd, buf, sizeof(buf))) > 0)
@@ -164,11 +164,12 @@ gr_tmp(int mfd)
int
gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr)
{
- char buf[8192], *end, *line, *p, *q, *r, t;
+ char *buf, *end, *line, *p, *q, *r, *tmp;
struct group *fgr;
const struct group *sgr;
- size_t len;
+ size_t len, size;
int eof, readlen;
+ char t;
if (old_gr == NULL && gr == NULL)
return(-1);
@@ -186,6 +187,10 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr)
if (sgr == NULL)
sgr = gr;
+ /* initialize the buffer */
+ if ((buf = malloc(size = 1024)) == NULL)
+ goto err;
+
eof = 0;
len = 0;
p = q = end = buf;
@@ -199,10 +204,16 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr)
if (q >= end) {
if (eof)
break;
- if ((size_t)(q - p) >= sizeof(buf)) {
- warnx("group line too long");
- errno = EINVAL; /* hack */
- goto err;
+ while ((size_t)(q - p) >= size) {
+ if ((tmp = realloc(buf, size * 2)) == NULL) {
+ warnx("group line too long");
+ goto err;
+ }
+ p = tmp + (p - buf);
+ q = tmp + (q - buf);
+ end = tmp + (end - buf);
+ buf = tmp;
+ size = size * 2;
}
if (p < end) {
q = memmove(buf, p, end -p);
@@ -210,7 +221,7 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr)
} else {
p = q = end = buf;
}
- readlen = read(ffd, end, sizeof(buf) - (end -buf));
+ readlen = read(ffd, end, size - (end - buf));
if (readlen == -1)
goto err;
else
@@ -219,7 +230,7 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr)
break;
end += len;
len = end - buf;
- if (len < (ssize_t)sizeof(buf)) {
+ if (len < size) {
eof = 1;
if (len > 0 && buf[len -1] != '\n')
++len, *end++ = '\n';
@@ -281,7 +292,7 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr)
if (write(tfd, q, end - q) != end - q)
goto err;
q = buf;
- readlen = read(ffd, buf, sizeof(buf));
+ readlen = read(ffd, buf, size);
if (readlen == 0)
break;
else
@@ -303,12 +314,12 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr)
write(tfd, "\n", 1) != 1)
goto err;
done:
- if (line != NULL)
- free(line);
+ free(line);
+ free(buf);
return (0);
err:
- if (line != NULL)
- free(line);
+ free(line);
+ free(buf);
return (-1);
}
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c
index af749d5..3e79e8d 100644
--- a/lib/libutil/pw_util.c
+++ b/lib/libutil/pw_util.c
@@ -226,7 +226,7 @@ pw_tmp(int mfd)
errno = ENAMETOOLONG;
return (-1);
}
- if ((tfd = mkostemp(tempname, O_SYNC)) == -1)
+ if ((tfd = mkostemp(tempname, 0)) == -1)
return (-1);
if (mfd != -1) {
while ((nr = read(mfd, buf, sizeof(buf))) > 0)
@@ -428,11 +428,12 @@ pw_make_v7(const struct passwd *pw)
int
pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw)
{
- char buf[8192], *end, *line, *p, *q, *r, t;
+ char *buf, *end, *line, *p, *q, *r, *tmp;
struct passwd *fpw;
const struct passwd *spw;
- size_t len;
+ size_t len, size;
int eof, readlen;
+ char t;
if (old_pw == NULL && pw == NULL)
return (-1);
@@ -450,6 +451,10 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw)
if (spw == NULL)
spw = pw;
+ /* initialize the buffer */
+ if ((buf = malloc(size = 1024)) == NULL)
+ goto err;
+
eof = 0;
len = 0;
p = q = end = buf;
@@ -463,10 +468,16 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw)
if (q >= end) {
if (eof)
break;
- if ((size_t)(q - p) >= sizeof(buf)) {
- warnx("passwd line too long");
- errno = EINVAL; /* hack */
- goto err;
+ while ((size_t)(q - p) >= size) {
+ if ((tmp = realloc(buf, size * 2)) == NULL) {
+ warnx("passwd line too long");
+ goto err;
+ }
+ p = tmp + (p - buf);
+ q = tmp + (q - buf);
+ end = tmp + (end - buf);
+ buf = tmp;
+ size = size * 2;
}
if (p < end) {
q = memmove(buf, p, end - p);
@@ -474,7 +485,7 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw)
} else {
p = q = end = buf;
}
- readlen = read(ffd, end, sizeof(buf) - (end - buf));
+ readlen = read(ffd, end, size - (end - buf));
if (readlen == -1)
goto err;
else
@@ -483,7 +494,7 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw)
break;
end += len;
len = end - buf;
- if (len < (ssize_t)sizeof(buf)) {
+ if (len < size) {
eof = 1;
if (len > 0 && buf[len - 1] != '\n')
++len, *end++ = '\n';
@@ -546,7 +557,7 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw)
if (write(tfd, q, end - q) != end - q)
goto err;
q = buf;
- readlen = read(ffd, buf, sizeof(buf));
+ readlen = read(ffd, buf, size);
if (readlen == 0)
break;
else
@@ -568,12 +579,12 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw)
write(tfd, "\n", 1) != 1)
goto err;
done:
- if (line != NULL)
- free(line);
+ free(line);
+ free(buf);
return (0);
err:
- if (line != NULL)
- free(line);
+ free(line);
+ free(buf);
return (-1);
}
OpenPOWER on IntegriCloud