[PATCH v2] genl: Add forward declaration to fix build warning
by Mat Martineau
The l_genl_msg_append_attrv() declaration in genl.h uses struct iovec *,
but there's no guarantee that sys/uio.h has been included (and
the genl user might not need that header itself).
---
v2: Use forward declaration instead of including system header
ell/genl.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ell/genl.h b/ell/genl.h
index 5df688b..c3f641f 100644
--- a/ell/genl.h
+++ b/ell/genl.h
@@ -31,6 +31,8 @@
extern "C" {
#endif
+struct iovec;
+
struct l_genl;
struct l_genl_family_info;
struct l_genl_family;
--
2.23.0
2 years, 8 months
[PATCH] genl: Include system header to fix build warning
by Mat Martineau
The l_genl_msg_append_attrv() declaration in genl.h uses struct iovec *,
but there's no guarantee that sys/uio.h has been included already (and
the genl user might not need that header itself). Within the ell code,
uio.h is already included by util.h which prevents build errors in ell
itself.
---
ell/genl.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/ell/genl.h b/ell/genl.h
index 5df688b..3a37ed5 100644
--- a/ell/genl.h
+++ b/ell/genl.h
@@ -26,6 +26,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
+#include <sys/uio.h>
#ifdef __cplusplus
extern "C" {
--
2.23.0
2 years, 8 months
[PATCH 1/5] tls: Fix tls12_prf buffer size
by Andrew Zaborowski
Enlarge the A(i) buffer to be able to hold the biggest possible hash
result (64) + the label + the biggest possible seed (64). As reported
by Will Dietz the buffer size issue could cause crashes with the bigger
hashes when built under clang.
Reported-by: Will Dietz <w(a)wdtz.org>
---
ell/tls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ell/tls.c b/ell/tls.c
index 0e06c27..5efd928 100644
--- a/ell/tls.c
+++ b/ell/tls.c
@@ -92,7 +92,7 @@ bool tls12_prf(enum l_checksum_type type,
{
struct l_checksum *hmac = l_checksum_new_hmac(type, secret, secret_len);
size_t a_len, chunk_len, prfseed_len = strlen(label) + seed_len;
- uint8_t a[128], prfseed[prfseed_len];
+ uint8_t a[64 + prfseed_len], prfseed[prfseed_len];
if (!hmac)
return false;
--
2.20.1
2 years, 8 months
[PATCH] utf8: cast to avoid left shift of negative value (ubsan)
by Will Dietz
---
ell/utf8.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ell/utf8.c b/ell/utf8.c
index e6b4b05..44601dc 100644
--- a/ell/utf8.c
+++ b/ell/utf8.c
@@ -98,7 +98,7 @@ LIB_EXPORT int l_utf8_get_codepoint(const char *str, size_t len, wchar_t *cp)
return 1;
}
- expect_bytes = __builtin_clz(~(str[0] << 24));
+ expect_bytes = __builtin_clz(~((unsigned char)str[0] << 24));
if (expect_bytes < 2 || expect_bytes > 4)
goto error;
--
2.24.0-rc1
2 years, 8 months
[PATCH] ell/tls: fix crash, don't index through adj. stack objs
by Will Dietz
Building with clang may make this more likely to crash,
problem is encountered on ell/tls.c:114 (before).
Also, use memmove as src/dst may overlap.
---
ell/tls.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/ell/tls.c b/ell/tls.c
index 0e06c27..50df446 100644
--- a/ell/tls.c
+++ b/ell/tls.c
@@ -92,7 +92,8 @@ bool tls12_prf(enum l_checksum_type type,
{
struct l_checksum *hmac = l_checksum_new_hmac(type, secret, secret_len);
size_t a_len, chunk_len, prfseed_len = strlen(label) + seed_len;
- uint8_t a[128], prfseed[prfseed_len];
+ uint8_t a[128 + prfseed_len];
+ uint8_t *prfseed = &a[128];
if (!hmac)
return false;
@@ -108,10 +109,10 @@ bool tls12_prf(enum l_checksum_type type,
/* Generate A(i) */
l_checksum_reset(hmac);
l_checksum_update(hmac, a, a_len);
- a_len = l_checksum_get_digest(hmac, a, sizeof(a));
+ a_len = l_checksum_get_digest(hmac, a, 128);
/* Append seed & generate output */
- memcpy(a + a_len, prfseed, prfseed_len);
+ memmove(a + a_len, prfseed, prfseed_len);
l_checksum_reset(hmac);
l_checksum_update(hmac, a, a_len + prfseed_len);
--
2.24.0-rc1
2 years, 8 months
[PATCH] random: Seed the fallback random number generator
by Ossama Othman
The random() PRNG is used as a fallback in case of getrandom() syscall
failure. However, the PRNG was not seeded prior to initial use,
resulting in the same predictable sequence of numbers being generated.
Explicitly seed the PRNG on initial use with random data retrieved
from the ELF binary loader to decrease predictability.
---
ell/random.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/ell/random.c b/ell/random.c
index 0b5b09e..99aa06e 100644
--- a/ell/random.c
+++ b/ell/random.c
@@ -28,6 +28,8 @@
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
+#include <time.h>
+#include <sys/auxv.h>
#include <sys/syscall.h>
#include "random.h"
@@ -95,11 +97,26 @@ LIB_EXPORT uint32_t l_getrandom_uint32(void)
{
int ret;
uint32_t u;
+ static unsigned int seed = 0; /* For fallback PRNG. */
ret = getrandom(&u, sizeof(u), GRND_NONBLOCK);
if (ret == sizeof(u))
return u;
- return random() * RAND_MAX + random();
+ if (seed == 0) {
+ /*
+ * Seed the fallback PRNG below with the
+ * process-specific random data supplied by the
+ * kernel, skipping the canary in the first half.
+ */
+ unsigned long addr =
+ getauxval(AT_RANDOM) + sizeof(void *);
+
+ seed = *((unsigned long *) addr) ^ time(NULL);
+
+ srandom(seed);
+ }
+
+ return random() * RAND_MAX + random();
}
--
2.20.1
2 years, 8 months
[PATCH] genl: Fix size calculation in msg_grow
by Andrew Zaborowski
"msg->size - needed" was the opposite of the value we actually need and
could end up being negative if we were appending an attribute larger
than the current message size.
---
ell/genl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ell/genl.c b/ell/genl.c
index 1260020..6177fd5 100644
--- a/ell/genl.c
+++ b/ell/genl.c
@@ -755,7 +755,7 @@ static bool msg_grow(struct l_genl_msg *msg, uint32_t needed)
if (msg->size >= msg->len + needed)
return true;
- grow_by = msg->size - needed;
+ grow_by = msg->len + needed - msg->size;
if (grow_by < 32)
grow_by = 128;
--
2.20.1
2 years, 8 months
[PATCH] dhcp: Add domain name option handler
by Tim Kourt
Add parser and accessor for domain name lease option.
---
ell/dhcp-lease.c | 16 +++++++++++++++-
ell/dhcp-private.h | 1 +
ell/dhcp.h | 1 +
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/ell/dhcp-lease.c b/ell/dhcp-lease.c
index a48cfa4..ba57322 100644
--- a/ell/dhcp-lease.c
+++ b/ell/dhcp-lease.c
@@ -45,6 +45,8 @@ void _dhcp_lease_free(struct l_dhcp_lease *lease)
return;
l_free(lease->dns);
+ l_free(lease->domain_name);
+
l_free(lease);
}
@@ -99,6 +101,10 @@ struct l_dhcp_lease *_dhcp_lease_parse_options(struct dhcp_message_iter *iter)
}
}
break;
+ case L_DHCP_OPTION_DOMAIN_NAME:
+ if (l >= 1)
+ lease->domain_name = l_strdup(v);
+ break;
default:
break;
}
@@ -124,7 +130,7 @@ struct l_dhcp_lease *_dhcp_lease_parse_options(struct dhcp_message_iter *iter)
return lease;
error:
- l_free(lease);
+ _dhcp_lease_free(lease);
return NULL;
}
@@ -201,6 +207,14 @@ LIB_EXPORT char **l_dhcp_lease_get_dns(const struct l_dhcp_lease *lease)
return dns_list;
}
+LIB_EXPORT char *l_dhcp_lease_get_domain_name(const struct l_dhcp_lease *lease)
+{
+ if (unlikely(!lease))
+ return NULL;
+
+ return l_strdup(lease->domain_name);
+}
+
LIB_EXPORT uint32_t l_dhcp_lease_get_t1(const struct l_dhcp_lease *lease)
{
if (unlikely(!lease))
diff --git a/ell/dhcp-private.h b/ell/dhcp-private.h
index 6554fc6..a75bb8b 100644
--- a/ell/dhcp-private.h
+++ b/ell/dhcp-private.h
@@ -120,6 +120,7 @@ struct l_dhcp_lease {
uint32_t t2;
uint32_t router;
uint32_t *dns;
+ char *domain_name;
};
struct l_dhcp_lease *_dhcp_lease_new(void);
diff --git a/ell/dhcp.h b/ell/dhcp.h
index c3a4988..b8a5b41 100644
--- a/ell/dhcp.h
+++ b/ell/dhcp.h
@@ -95,6 +95,7 @@ char *l_dhcp_lease_get_netmask(const struct l_dhcp_lease *lease);
char *l_dhcp_lease_get_broadcast(const struct l_dhcp_lease *lease);
char *l_dhcp_lease_get_server_id(const struct l_dhcp_lease *lease);
char **l_dhcp_lease_get_dns(const struct l_dhcp_lease *lease);
+char *l_dhcp_lease_get_domain_name(const struct l_dhcp_lease *lease);
uint32_t l_dhcp_lease_get_t1(const struct l_dhcp_lease *lease);
uint32_t l_dhcp_lease_get_t2(const struct l_dhcp_lease *lease);
--
2.13.6
2 years, 8 months
[PATCH 1/2] dhcp: Stop client before notifying owner
by Tim Kourt
This enables the owner of the client object to restart it.
---
ell/dhcp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ell/dhcp.c b/ell/dhcp.c
index 22d903e..132d973 100644
--- a/ell/dhcp.c
+++ b/ell/dhcp.c
@@ -950,9 +950,11 @@ static void dhcp_client_rx_message(const void *data, size_t len, void *userdata)
case DHCP_STATE_RENEWING:
case DHCP_STATE_REBINDING:
if (msg_type == DHCP_MESSAGE_TYPE_NAK) {
+ l_dhcp_client_stop(client);
+
dhcp_client_event_notify(client,
L_DHCP_CLIENT_EVENT_NO_LEASE);
- goto error;
+ return;
}
if (msg_type != DHCP_MESSAGE_TYPE_ACK)
--
2.13.6
2 years, 8 months
[PATCH] unit: fix build with musl libc
by Natanael Copa
Define WAIT_ANY if needed. It is not specified in POSIX so we cannot
expect it to be defined.
This fixes build with musl libc.
---
unit/test-dbus-message-fds.c | 4 ++++
unit/test-dbus-properties.c | 4 ++++
unit/test-dbus.c | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/unit/test-dbus-message-fds.c b/unit/test-dbus-message-fds.c
index 6f68bae..6a23141 100644
--- a/unit/test-dbus-message-fds.c
+++ b/unit/test-dbus-message-fds.c
@@ -41,6 +41,10 @@
#define WAIT_ANY (-1) /* Any process */
#endif
+#ifndef WAIT_ANY
+#define WAIT_ANY (-1)
+#endif
+
#define TEST_BUS_ADDRESS "unix:path=/tmp/ell-test-bus"
static pid_t dbus_daemon_pid = -1;
diff --git a/unit/test-dbus-properties.c b/unit/test-dbus-properties.c
index 1844ec0..7847c10 100644
--- a/unit/test-dbus-properties.c
+++ b/unit/test-dbus-properties.c
@@ -38,6 +38,10 @@
#define WAIT_ANY (-1) /* Any process */
#endif
+#ifndef WAIT_ANY
+#define WAIT_ANY (-1)
+#endif
+
#define TEST_BUS_ADDRESS "unix:path=/tmp/ell-test-bus"
static pid_t dbus_daemon_pid = -1;
diff --git a/unit/test-dbus.c b/unit/test-dbus.c
index 67f0a7b..05de3f9 100644
--- a/unit/test-dbus.c
+++ b/unit/test-dbus.c
@@ -35,6 +35,10 @@
#define WAIT_ANY (-1) /* Any process */
#endif
+#ifndef WAIT_ANY
+#define WAIT_ANY (-1)
+#endif
+
#define TEST_BUS_ADDRESS "unix:path=/tmp/ell-test-bus"
static pid_t dbus_daemon_pid = -1;
--
2.23.0
2 years, 8 months