summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2020-12-18 16:58:59 +0000
committerclaudio <claudio@openbsd.org>2020-12-18 16:58:59 +0000
commit45a663919aacd606176ded2c5f4cad03cac12dff (patch)
tree204925ec1b0114fe3e4519daede934a98aa5dd1a
parentAdd support for the i.MX8MP USB clocks. (diff)
downloadwireguard-openbsd-45a663919aacd606176ded2c5f4cad03cac12dff.tar.xz
wireguard-openbsd-45a663919aacd606176ded2c5f4cad03cac12dff.zip
In io_str_read() return 0-length strings as NULL pointers instead of
empty strings. There are no empty strings being passed around but a fair amount of optional strings and this will simplify this code. OK tb@
-rw-r--r--usr.sbin/rpki-client/io.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.sbin/rpki-client/io.c b/usr.sbin/rpki-client/io.c
index 9031760ef71..9b2b8feb021 100644
--- a/usr.sbin/rpki-client/io.c
+++ b/usr.sbin/rpki-client/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.10 2020/12/02 15:31:15 claudio Exp $ */
+/* $OpenBSD: io.c,v 1.11 2020/12/18 16:58:59 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -153,7 +153,7 @@ io_buf_read_alloc(int fd, void **res, size_t *sz)
}
/*
- * Read a string (which may just be \0 and zero-length), allocating
+ * Read a string (returns NULL for zero-length strings), allocating
* space for it.
*/
void
@@ -162,6 +162,10 @@ io_str_read(int fd, char **res)
size_t sz;
io_simple_read(fd, &sz, sizeof(size_t));
+ if (sz == 0) {
+ *res = NULL;
+ return;
+ }
if ((*res = calloc(sz + 1, 1)) == NULL)
err(1, NULL);
io_simple_read(fd, *res, sz);