Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove strndupa to build on musl #139

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions systemd/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <unistd.h>
#include <net/if.h>

#include "macro.h"
#include "util.h"

int safe_atou(const char *s, unsigned *ret_u) {
Expand Down Expand Up @@ -112,7 +113,8 @@ static int assign_address(const char *s,
int parse_sockaddr(const char *s,
union sockaddr_union *addr, unsigned *addr_len) {

char *e, *n;
char *e;
_cleanup_free_ char *n = NULL;
unsigned u;
int r;

Expand All @@ -123,7 +125,7 @@ int parse_sockaddr(const char *s,
if (!e)
return -EINVAL;

n = strndupa(s+1, e-s-1);
n = strndup(s+1, e-s-1);

errno = 0;
if (inet_pton(AF_INET6, n, &addr->in6.sin6_addr) <= 0)
Expand Down Expand Up @@ -158,7 +160,7 @@ int parse_sockaddr(const char *s,
if (u <= 0 || u > 0xFFFF)
return -EINVAL;

n = strndupa(s, e-s);
n = strndup(s, e-s);
return assign_address(n, u, addr, addr_len);

} else {
Expand Down
Loading