From b7026bf248948a6a30386ddbcc137f48f369a51e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 Aug 2008 22:39:54 +0200 Subject: add a few more gcc warning flags and fix quite a few problems found by doing so --- src/pulsecore/parseaddr.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/pulsecore/parseaddr.c') diff --git a/src/pulsecore/parseaddr.c b/src/pulsecore/parseaddr.c index f2b6b2cf..c5cd7fe7 100644 --- a/src/pulsecore/parseaddr.c +++ b/src/pulsecore/parseaddr.c @@ -51,20 +51,29 @@ static char *parse_host(const char *s, uint16_t *ret_port) { if (!(e = strchr(s+1, ']'))) return NULL; - if (e[1] == ':') - *ret_port = atoi(e+2); - else if (e[1] != 0) + if (e[1] == ':') { + uint32_t p; + + if (pa_atou(e+2, &p) < 0) + return NULL; + + *ret_port = (uint16_t) p; + } else if (e[1] != 0) return NULL; - return pa_xstrndup(s+1, e-s-1); + return pa_xstrndup(s+1, (size_t) (e-s-1)); } else { char *e; + uint32_t p; if (!(e = strrchr(s, ':'))) return pa_xstrdup(s); - *ret_port = atoi(e+1); - return pa_xstrndup(s, e-s); + if (pa_atou(e+1, &p) < 0) + return NULL; + + *ret_port = (uint16_t) p; + return pa_xstrndup(s, (size_t) (e-s)); } } -- cgit