summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/core-scache.c2
-rw-r--r--src/pulsecore/core-util.c17
-rw-r--r--src/pulsecore/inet_ntop.c4
-rw-r--r--src/pulsecore/namereg.c2
-rw-r--r--src/pulsecore/pdispatch.c2
-rw-r--r--src/pulsecore/pid.c2
-rw-r--r--src/pulsecore/protocol-esound.c4
-rw-r--r--src/pulsecore/protocol-http.c4
-rw-r--r--src/pulsecore/protocol-native.c2
-rw-r--r--src/pulsecore/shm.c3
-rw-r--r--src/pulsecore/socket-client.c2
-rw-r--r--src/pulsecore/socket-server.c14
-rw-r--r--src/pulsecore/socket-util.c14
-rw-r--r--src/pulsecore/strbuf.c1
-rw-r--r--src/pulsecore/x11wrap.c3
15 files changed, 41 insertions, 35 deletions
diff --git a/src/pulsecore/core-scache.c b/src/pulsecore/core-scache.c
index cb272784..d5fe6f20 100644
--- a/src/pulsecore/core-scache.c
+++ b/src/pulsecore/core-scache.c
@@ -415,7 +415,7 @@ int pa_scache_add_directory_lazy(pa_core *c, const char *pathname) {
if (e->d_name[0] == '.')
continue;
- snprintf(p, sizeof(p), "%s/%s", pathname, e->d_name);
+ pa_snprintf(p, sizeof(p), "%s/%s", pathname, e->d_name);
add_file(c, p);
}
}
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 98790484..e61be704 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -431,6 +431,8 @@ char *pa_sprintf_malloc(const char *format, ...) {
r = vsnprintf(c, size, format, ap);
va_end(ap);
+ c[size-1] = 0;
+
if (r > -1 && r < size)
return c;
@@ -453,13 +455,14 @@ char *pa_vsprintf_malloc(const char *format, va_list ap) {
int r;
va_list aq;
- va_copy(aq, ap);
-
c = pa_xrealloc(c, size);
- r = vsnprintf(c, size, format, aq);
+ va_copy(aq, ap);
+ r = vsnprintf(c, size, format, aq);
va_end(aq);
+ c[size-1] = 0;
+
if (r > -1 && r < size)
return c;
@@ -1146,17 +1149,17 @@ char *pa_runtime_path(const char *fn, char *s, size_t l) {
if ((e = getenv("PULSE_RUNTIME_PATH"))) {
if (fn)
- snprintf(s, l, "%s%c%s", e, PATH_SEP, fn);
+ pa_snprintf(s, l, "%s%c%s", e, PATH_SEP, fn);
else
- snprintf(s, l, "%s", e);
+ pa_snprintf(s, l, "%s", e);
} else {
char u[256];
if (fn)
- snprintf(s, l, "%s%s%c%s", PA_USER_RUNTIME_PATH_PREFIX, pa_get_user_name(u, sizeof(u)), PATH_SEP, fn);
+ pa_snprintf(s, l, "%s%s%c%s", PA_USER_RUNTIME_PATH_PREFIX, pa_get_user_name(u, sizeof(u)), PATH_SEP, fn);
else
- snprintf(s, l, "%s%s", PA_USER_RUNTIME_PATH_PREFIX, pa_get_user_name(u, sizeof(u)));
+ pa_snprintf(s, l, "%s%s", PA_USER_RUNTIME_PATH_PREFIX, pa_get_user_name(u, sizeof(u)));
}
diff --git a/src/pulsecore/inet_ntop.c b/src/pulsecore/inet_ntop.c
index 302369f7..041bc09b 100644
--- a/src/pulsecore/inet_ntop.c
+++ b/src/pulsecore/inet_ntop.c
@@ -47,7 +47,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) {
switch (af) {
case AF_INET:
- snprintf(dst, cnt, "%d.%d.%d.%d",
+ pa_snprintf(dst, cnt, "%d.%d.%d.%d",
#ifdef WORDS_BIGENDIAN
(int)(in->s_addr >> 24) & 0xff,
(int)(in->s_addr >> 16) & 0xff,
@@ -61,7 +61,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) {
#endif
break;
case AF_INET6:
- snprintf(dst, cnt, "%x:%x:%x:%x:%x:%x:%x:%x",
+ pa_snprintf(dst, cnt, "%x:%x:%x:%x:%x:%x:%x:%x",
in6->s6_addr[ 0] << 8 | in6->s6_addr[ 1],
in6->s6_addr[ 2] << 8 | in6->s6_addr[ 3],
in6->s6_addr[ 4] << 8 | in6->s6_addr[ 5],
diff --git a/src/pulsecore/namereg.c b/src/pulsecore/namereg.c
index 7f66af05..5fae3fc3 100644
--- a/src/pulsecore/namereg.c
+++ b/src/pulsecore/namereg.c
@@ -142,7 +142,7 @@ const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t
k = pa_xnew(char, l+4);
for (i = 2; i <= 99; i++) {
- snprintf(k, l+4, "%s.%u", name, i);
+ pa_snprintf(k, l+4, "%s.%u", name, i);
if (!(e = pa_hashmap_get(c->namereg, k)))
break;
diff --git a/src/pulsecore/pdispatch.c b/src/pulsecore/pdispatch.c
index 10238acb..f5ec1c09 100644
--- a/src/pulsecore/pdispatch.c
+++ b/src/pulsecore/pdispatch.c
@@ -206,7 +206,7 @@ int pa_pdispatch_run(pa_pdispatch *pd, pa_packet*packet, const pa_creds *creds,
char t[256];
char const *p;
if (!(p = command_names[command]))
- snprintf((char*) (p = t), sizeof(t), "%u", command);
+ pa_snprintf((char*) (p = t), sizeof(t), "%u", command);
pa_log("Recieved opcode <%s>", p);
}
diff --git a/src/pulsecore/pid.c b/src/pulsecore/pid.c
index 5e670e17..efb6e64e 100644
--- a/src/pulsecore/pid.c
+++ b/src/pulsecore/pid.c
@@ -172,7 +172,7 @@ int pa_pid_file_create(void) {
goto fail;
}
- snprintf(t, sizeof(t), "%lu\n", (unsigned long) getpid());
+ pa_snprintf(t, sizeof(t), "%lu\n", (unsigned long) getpid());
l = strlen(t);
if (pa_loop_write(fd, t, l, NULL) != (ssize_t) l) {
diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index 6a5c6127..fe0b879b 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -626,7 +626,7 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v
if (strncmp(ce->name, SCACHE_PREFIX, sizeof(SCACHE_PREFIX)-1) == 0)
strncpy(name, ce->name+sizeof(SCACHE_PREFIX)-1, ESD_NAME_MAX);
else
- snprintf(name, ESD_NAME_MAX, "native.%s", ce->name);
+ pa_snprintf(name, ESD_NAME_MAX, "native.%s", ce->name);
connection_write(c, name, ESD_NAME_MAX);
/* rate */
@@ -1194,7 +1194,7 @@ static void on_connection(pa_socket_server*s, pa_iochannel *io, void *userdata)
pa_iochannel_set_callback(c->io, io_callback, c);
pa_iochannel_socket_peer_to_string(io, pname, sizeof(pname));
- snprintf(cname, sizeof(cname), "EsounD client (%s)", pname);
+ pa_snprintf(cname, sizeof(cname), "EsounD client (%s)", pname);
assert(p->core);
c->client = pa_client_new(p->core, __FILE__, cname);
assert(c->client);
diff --git a/src/pulsecore/protocol-http.c b/src/pulsecore/protocol-http.c
index 3541721a..eb5bda0d 100644
--- a/src/pulsecore/protocol-http.c
+++ b/src/pulsecore/protocol-http.c
@@ -69,7 +69,7 @@ static void http_response(struct connection *c, int code, const char *msg, const
assert(msg);
assert(mime);
- snprintf(s, sizeof(s),
+ pa_snprintf(s, sizeof(s),
"HTTP/1.0 %i %s\n"
"Connection: close\n"
"Content-Type: %s\n"
@@ -90,7 +90,7 @@ static void http_message(struct connection *c, int code, const char *msg, const
if (!text)
text = msg;
- snprintf(s, sizeof(s),
+ pa_snprintf(s, sizeof(s),
"<?xml version=\"1.0\"?>\n"
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
"<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>%s</title></head>\n"
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 86455693..97345f00 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -2381,7 +2381,7 @@ static void on_connection(PA_GCC_UNUSED pa_socket_server*s, pa_iochannel *io, vo
c->version = 8;
c->protocol = p;
pa_iochannel_socket_peer_to_string(io, pname, sizeof(pname));
- snprintf(cname, sizeof(cname), "Native client (%s)", pname);
+ pa_snprintf(cname, sizeof(cname), "Native client (%s)", pname);
assert(p->core);
c->client = pa_client_new(p->core, __FILE__, cname);
assert(c->client);
diff --git a/src/pulsecore/shm.c b/src/pulsecore/shm.c
index 8c7fb4db..8ef02f61 100644
--- a/src/pulsecore/shm.c
+++ b/src/pulsecore/shm.c
@@ -42,6 +42,7 @@
#include <pulsecore/core-error.h>
#include <pulsecore/log.h>
#include <pulsecore/random.h>
+#include <pulsecore/core-util.h>
#include <pulse/xmalloc.h>
#include "shm.h"
@@ -53,7 +54,7 @@
#define MAX_SHM_SIZE (1024*1024*20)
static char *segment_name(char *fn, size_t l, unsigned id) {
- snprintf(fn, l, "/pulse-shm-%u", id);
+ pa_snprintf(fn, l, "/pulse-shm-%u", id);
return fn;
}
diff --git a/src/pulsecore/socket-client.c b/src/pulsecore/socket-client.c
index b83bfead..9e7280dd 100644
--- a/src/pulsecore/socket-client.c
+++ b/src/pulsecore/socket-client.c
@@ -445,7 +445,7 @@ pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, const char*nam
struct addrinfo hints;
char port[12];
- snprintf(port, sizeof(port), "%u", (unsigned) a.port);
+ pa_snprintf(port, sizeof(port), "%u", (unsigned) a.port);
memset(&hints, 0, sizeof(hints));
hints.ai_family = a.type == PA_PARSED_ADDRESS_TCP4 ? PF_INET : (a.type == PA_PARSED_ADDRESS_TCP6 ? PF_INET6 : PF_UNSPEC);
diff --git a/src/pulsecore/socket-server.c b/src/pulsecore/socket-server.c
index b5a6dc31..c900ff32 100644
--- a/src/pulsecore/socket-server.c
+++ b/src/pulsecore/socket-server.c
@@ -438,14 +438,14 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) {
if (!pa_get_fqdn(fqdn, sizeof(fqdn)))
return NULL;
- snprintf(c, l, "tcp6:%s:%u", fqdn, (unsigned) ntohs(sa.sin6_port));
+ pa_snprintf(c, l, "tcp6:%s:%u", fqdn, (unsigned) ntohs(sa.sin6_port));
} else if (memcmp(&in6addr_loopback, &sa.sin6_addr, sizeof(in6addr_loopback)) == 0) {
char hn[256];
if (!pa_get_host_name(hn, sizeof(hn)))
return NULL;
- snprintf(c, l, "{%s}tcp6:localhost:%u", hn, (unsigned) ntohs(sa.sin6_port));
+ pa_snprintf(c, l, "{%s}tcp6:localhost:%u", hn, (unsigned) ntohs(sa.sin6_port));
} else {
char ip[INET6_ADDRSTRLEN];
@@ -454,7 +454,7 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) {
return NULL;
}
- snprintf(c, l, "tcp6:[%s]:%u", ip, (unsigned) ntohs(sa.sin6_port));
+ pa_snprintf(c, l, "tcp6:[%s]:%u", ip, (unsigned) ntohs(sa.sin6_port));
}
return c;
@@ -474,13 +474,13 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) {
if (!pa_get_fqdn(fqdn, sizeof(fqdn)))
return NULL;
- snprintf(c, l, "tcp:%s:%u", fqdn, (unsigned) ntohs(sa.sin_port));
+ pa_snprintf(c, l, "tcp:%s:%u", fqdn, (unsigned) ntohs(sa.sin_port));
} else if (sa.sin_addr.s_addr == INADDR_LOOPBACK) {
char hn[256];
if (!pa_get_host_name(hn, sizeof(hn)))
return NULL;
- snprintf(c, l, "{%s}tcp:localhost:%u", hn, (unsigned) ntohs(sa.sin_port));
+ pa_snprintf(c, l, "{%s}tcp:localhost:%u", hn, (unsigned) ntohs(sa.sin_port));
} else {
char ip[INET_ADDRSTRLEN];
@@ -489,7 +489,7 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) {
return NULL;
}
- snprintf(c, l, "tcp:[%s]:%u", ip, (unsigned) ntohs(sa.sin_port));
+ pa_snprintf(c, l, "tcp:[%s]:%u", ip, (unsigned) ntohs(sa.sin_port));
}
@@ -505,7 +505,7 @@ char *pa_socket_server_get_address(pa_socket_server *s, char *c, size_t l) {
if (!pa_get_host_name(hn, sizeof(hn)))
return NULL;
- snprintf(c, l, "{%s}unix:%s", hn, s->filename);
+ pa_snprintf(c, l, "{%s}unix:%s", hn, s->filename);
return c;
}
diff --git a/src/pulsecore/socket-util.c b/src/pulsecore/socket-util.c
index 05cb3369..511f12ef 100644
--- a/src/pulsecore/socket-util.c
+++ b/src/pulsecore/socket-util.c
@@ -85,7 +85,7 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
#ifndef OS_IS_WIN32
if (fstat(fd, &st) < 0) {
- snprintf(c, l, "Invalid client fd");
+ pa_snprintf(c, l, "Invalid client fd");
return;
}
#endif
@@ -108,7 +108,7 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
if (sa.sa.sa_family == AF_INET) {
uint32_t ip = ntohl(sa.in.sin_addr.s_addr);
- snprintf(c, l, "TCP/IP client from %i.%i.%i.%i:%u",
+ pa_snprintf(c, l, "TCP/IP client from %i.%i.%i.%i:%u",
ip >> 24,
(ip >> 16) & 0xFF,
(ip >> 8) & 0xFF,
@@ -121,27 +121,27 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) {
res = inet_ntop(AF_INET6, &sa.in6.sin6_addr, buf, sizeof(buf));
if (res) {
- snprintf(c, l, "TCP/IP client from [%s]:%u", buf, ntohs(sa.in6.sin6_port));
+ pa_snprintf(c, l, "TCP/IP client from [%s]:%u", buf, ntohs(sa.in6.sin6_port));
return;
}
#ifdef HAVE_SYS_UN_H
} else if (sa.sa.sa_family == AF_UNIX) {
- snprintf(c, l, "UNIX socket client");
+ pa_snprintf(c, l, "UNIX socket client");
return;
#endif
}
}
#ifndef OS_IS_WIN32
- snprintf(c, l, "Unknown network client");
+ pa_snprintf(c, l, "Unknown network client");
return;
} else if (S_ISCHR(st.st_mode) && (fd == 0 || fd == 1)) {
- snprintf(c, l, "STDIN/STDOUT client");
+ pa_snprintf(c, l, "STDIN/STDOUT client");
return;
}
#endif /* OS_IS_WIN32 */
- snprintf(c, l, "Unknown client");
+ pa_snprintf(c, l, "Unknown client");
}
int pa_socket_low_delay(int fd) {
diff --git a/src/pulsecore/strbuf.c b/src/pulsecore/strbuf.c
index a3ddc114..2c66f5fa 100644
--- a/src/pulsecore/strbuf.c
+++ b/src/pulsecore/strbuf.c
@@ -153,6 +153,7 @@ int pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) {
va_start(ap, format);
r = vsnprintf(CHUNK_TO_TEXT(c), size, format, ap);
+ CHUNK_TO_TEXT(c)[size-1] = 0;
va_end(ap);
if (r > -1 && r < size) {
diff --git a/src/pulsecore/x11wrap.c b/src/pulsecore/x11wrap.c
index 6a6a2692..067b7df0 100644
--- a/src/pulsecore/x11wrap.c
+++ b/src/pulsecore/x11wrap.c
@@ -29,6 +29,7 @@
#include <pulsecore/llist.h>
#include <pulsecore/log.h>
#include <pulsecore/props.h>
+#include <pulsecore/core-util.h>
#include "x11wrap.h"
@@ -198,7 +199,7 @@ pa_x11_wrapper* pa_x11_wrapper_get(pa_core *c, const char *name) {
pa_x11_wrapper *w;
assert(c);
- snprintf(t, sizeof(t), "x11-wrapper%s%s", name ? "-" : "", name ? name : "");
+ pa_snprintf(t, sizeof(t), "x11-wrapper%s%s", name ? "-" : "", name ? name : "");
if ((w = pa_property_get(c, t)))
return pa_x11_wrapper_ref(w);