From: Lennart Poettering Date: Thu, 19 Oct 2023 14:30:23 +0000 (+0200) Subject: iovec-util: make IOVEC_MAKE_STRING() safer X-Git-Tag: v255-rc1~186^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9599ea28b4e82ae6e25f642a04515e11505b3145;p=thirdparty%2Fsystemd.git iovec-util: make IOVEC_MAKE_STRING() safer Let's not accept arbitrary types, but only char* and const char*. --- diff --git a/src/basic/iovec-util.h b/src/basic/iovec-util.h index d46455371b1..245c6160176 100644 --- a/src/basic/iovec-util.h +++ b/src/basic/iovec-util.h @@ -35,10 +35,10 @@ static inline bool IOVEC_INCREMENT(struct iovec *i, size_t n, size_t k) { #define IOVEC_NULL (const struct iovec) {} #define IOVEC_MAKE(base, len) (struct iovec) { .iov_base = (base), .iov_len = (len) } -#define IOVEC_MAKE_STRING(string) \ - ({ \ - char *_s = (char*) (string); \ - IOVEC_MAKE(_s, strlen(_s)); \ +#define IOVEC_MAKE_STRING(string) \ + ({ \ + const char *_s = (string); \ + IOVEC_MAKE((char*) _s, strlen(_s)); \ }) char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value);