]> code.delx.au - pulseaudio/commitdiff
Convert most snprintf() calls to pa_snprintf()
authorLennart Poettering <lennart@poettering.net>
Wed, 25 Jul 2007 16:23:03 +0000 (16:23 +0000)
committerLennart Poettering <lennart@poettering.net>
Wed, 25 Jul 2007 16:23:03 +0000 (16:23 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1534 fefdeb5f-60dc-0310-8127-8f9354f1896f

30 files changed:
src/Makefile.am
src/daemon/cpulimit.c
src/daemon/dumpmodules.c
src/modules/gconf/gconf-helper.c
src/modules/module-combine.c
src/modules/module-detect.c
src/modules/module-hal-detect.c
src/modules/module-sine.c
src/modules/module-tunnel.c
src/pulse/browser.c
src/pulse/channelmap.c
src/pulse/context.c
src/pulse/sample.c
src/pulse/util.c
src/pulse/volume.c
src/pulsecore/core-scache.c
src/pulsecore/core-util.c
src/pulsecore/inet_ntop.c
src/pulsecore/namereg.c
src/pulsecore/pdispatch.c
src/pulsecore/pid.c
src/pulsecore/protocol-esound.c
src/pulsecore/protocol-http.c
src/pulsecore/protocol-native.c
src/pulsecore/shm.c
src/pulsecore/socket-client.c
src/pulsecore/socket-server.c
src/pulsecore/socket-util.c
src/pulsecore/strbuf.c
src/pulsecore/x11wrap.c

index 2e37b2959dfc370283578f9a4c25faeed296291f..cda357335406a7e9be58880ca4a66278d3e49c01 100644 (file)
@@ -1292,7 +1292,7 @@ module_gconf_la_LIBADD = $(AM_LIBADD) libpulsecore.la
 module_gconf_la_CFLAGS = $(AM_CFLAGS) -DPA_GCONF_HELPER=\"$(pulselibexecdir)/gconf-helper\"
 
 gconf_helper_SOURCES = modules/gconf/gconf-helper.c
-gconf_helper_LDADD = $(AM_LDADD) $(GCONF_LIBS)
+gconf_helper_LDADD = $(AM_LDADD) $(GCONF_LIBS) libpulsecore.la
 gconf_helper_CFLAGS = $(AM_CFLAGS) $(GCONF_CFLAGS)
 gconf_helper_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
index d4ac1d869d013506190352734a2d3cf4316c8227..6536f46828ff11e3db5017742c9143602f3afb2d 100644 (file)
@@ -130,7 +130,7 @@ static void signal_handler(int sig) {
         time(&now);
 
 #ifdef PRINT_CPU_LOAD
-        snprintf(t, sizeof(t), "Using %0.1f%% CPU\n", (double)CPUTIME_INTERVAL_SOFT/(now-last_time)*100);
+        pa_snprintf(t, sizeof(t), "Using %0.1f%% CPU\n", (double)CPUTIME_INTERVAL_SOFT/(now-last_time)*100);
         write_err(t);
 #endif
 
index 6743622ac645de4620dc3c43a7bbe139aed0f1f4..cbbf94f3ced59d575a35d982a30fc51d97996cc3 100644 (file)
@@ -35,6 +35,7 @@
 #include <pulse/util.h>
 
 #include <pulsecore/modinfo.h>
+#include <pulsecore/core-util.h>
 
 #include "dumpmodules.h"
 
@@ -93,7 +94,7 @@ static int is_preloaded(const char *name) {
         if (l->address)
             continue;
 
-        snprintf(buf, sizeof(buf), "%s", l->name);
+        pa_snprintf(buf, sizeof(buf), "%s", l->name);
         if ((e = strrchr(buf, '.')))
             *e = 0;
 
@@ -137,7 +138,7 @@ void pa_dump_modules(pa_daemon_conf *c, int argc, char * const argv[]) {
             if (strlen(l->name) <= sizeof(PREFIX)-1 || strncmp(l->name, PREFIX, sizeof(PREFIX)-1))
                 continue;
 
-            snprintf(buf, sizeof(buf), "%s", l->name);
+            pa_snprintf(buf, sizeof(buf), "%s", l->name);
             if ((e = strrchr(buf, '.')))
                 *e = 0;
 
index 3483b8451b84051c9bd2388a5a834cb469cca713..abd132875e8c6b75b53cb9700ae479d826e6529e 100644 (file)
@@ -32,6 +32,8 @@
 #include <gconf/gconf-client.h>
 #include <glib.h>
 
+#include <pulsecore/core-util.h>
+
 #define PA_GCONF_ROOT "/system/pulseaudio"
 #define PA_GCONF_PATH_MODULES PA_GCONF_ROOT"/modules"
 
@@ -40,13 +42,13 @@ static void handle_module(GConfClient *client, const char *name) {
     gboolean enabled, locked;
     int i;
 
-    snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/locked", name);
+    pa_snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/locked", name);
     locked = gconf_client_get_bool(client, p, FALSE);
 
     if (locked)
         return;
 
-    snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/enabled", name);
+    pa_snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/enabled", name);
     enabled = gconf_client_get_bool(client, p, FALSE);
 
     printf("%c%s%c", enabled ? '+' : '-', name, 0);
@@ -56,11 +58,11 @@ static void handle_module(GConfClient *client, const char *name) {
         for (i = 0; i < 10; i++) {
             gchar *n, *a;
 
-            snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/name%i", name, i);
+            pa_snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/name%i", name, i);
             if (!(n = gconf_client_get_string(client, p, NULL)) || !*n)
                 break;
 
-            snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/args%i", name, i);
+            pa_snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/args%i", name, i);
             a = gconf_client_get_string(client, p, NULL);
 
             printf("%s%c%s%c", n, 0, a ? a : "", 0);
index 716c20b2403fcebd7c0aa8ce3a80689f935c3050..b6d718de2affe084c4929a2359d8404c07efbfac 100644 (file)
@@ -251,7 +251,7 @@ static struct output *output_new(struct userdata *u, pa_sink *sink, int resample
             0,
             NULL);
 
-    snprintf(t, sizeof(t), "Output stream #%u of sink %s", u->n_outputs+1, u->sink->name);
+    pa_snprintf(t, sizeof(t), "Output stream #%u of sink %s", u->n_outputs+1, u->sink->name);
 
     pa_sink_input_new_data_init(&data);
     data.sink = sink;
index 29d6fc27b07d81e1cbf3ca411b9f7b16cc314eae..190cda9dc6f35ac9fe24b4cc6fdcfb58d2d5288e 100644 (file)
@@ -96,7 +96,7 @@ static int detect_alsa(pa_core *c, int just_one) {
         if (subdevice != 0)
             continue;
 
-        snprintf(args, sizeof(args), "device=hw:%u", device);
+        pa_snprintf(args, sizeof(args), "device=hw:%u", device);
         if (!pa_module_load(c, is_sink ? "module-alsa-sink" : "module-alsa-source", args))
             continue;
 
@@ -148,16 +148,16 @@ static int detect_oss(pa_core *c, int just_one) {
 
         if (sscanf(line, "%u: ", &device) == 1) {
             if (device == 0)
-                snprintf(args, sizeof(args), "device=/dev/dsp");
+                pa_snprintf(args, sizeof(args), "device=/dev/dsp");
             else
-                snprintf(args, sizeof(args), "device=/dev/dsp%u", device);
+                pa_snprintf(args, sizeof(args), "device=/dev/dsp%u", device);
 
             if (!pa_module_load(c, "module-oss", args))
                 continue;
 
         } else if (sscanf(line, "pcm%u: ", &device) == 1) {
             /* FreeBSD support, the devices are named /dev/dsp0.0, dsp0.1 and so on */
-            snprintf(args, sizeof(args), "device=/dev/dsp%u.0", device);
+            pa_snprintf(args, sizeof(args), "device=/dev/dsp%u.0", device);
 
             if (!pa_module_load(c, "module-oss", args))
                 continue;
@@ -193,7 +193,7 @@ static int detect_solaris(pa_core *c, int just_one) {
     if (!S_ISCHR(s.st_mode))
         return 0;
 
-    snprintf(args, sizeof(args), "device=%s", dev);
+    pa_snprintf(args, sizeof(args), "device=%s", dev);
 
     if (!pa_module_load(c, "module-solaris", args))
         return 0;
index 1f48a452e795107e5f6025b806c0b976744eca38..6ae9cd0c7d508be9a8c75c1836bcac4051aad0b0 100644 (file)
@@ -182,10 +182,10 @@ static pa_module* hal_device_load_alsa(struct userdata *u, const char *udi,
 
     if (type == ALSA_TYPE_SINK) {
         module_name = "module-alsa-sink";
-        snprintf(args, sizeof(args), "device=hw:%u sink_name=alsa_output.%s", card, strip_udi(udi));
+        pa_snprintf(args, sizeof(args), "device=hw:%u sink_name=alsa_output.%s", card, strip_udi(udi));
     } else {
         module_name = "module-alsa-source";
-        snprintf(args, sizeof(args), "device=hw:%u source_name=alsa_input.%s", card, strip_udi(udi));
+        pa_snprintf(args, sizeof(args), "device=hw:%u source_name=alsa_input.%s", card, strip_udi(udi));
     }
 
     pa_log_debug("Loading %s with arguments '%s'", module_name, args);
@@ -244,7 +244,7 @@ static pa_module* hal_device_load_oss(struct userdata *u, const char *udi,
     if (!device || dbus_error_is_set(error))
         return NULL;
 
-    snprintf(args, sizeof(args), "device=%s sink_name=oss_output.%s source_name=oss_input.%s", device, strip_udi(udi), strip_udi(udi));
+    pa_snprintf(args, sizeof(args), "device=%s sink_name=oss_output.%s source_name=oss_input.%s", device, strip_udi(udi), strip_udi(udi));
     libhal_free_string(device);
 
     pa_log_debug("Loading module-oss with arguments '%s'", args);
index a784f218989c8ba26fcc9fac058207357b83d90e..797ba44052303893e969fad75f983b3a05bf40ce 100644 (file)
@@ -36,6 +36,7 @@
 #include <pulsecore/modargs.h>
 #include <pulsecore/namereg.h>
 #include <pulsecore/log.h>
+#include <pulsecore/core-util.h>
 
 #include "module-sine-symdef.h"
 
@@ -155,7 +156,7 @@ int pa__init(pa_core *c, pa_module*m) {
     calc_sine(p, pa_memblock_get_length(u->memblock), frequency);
     pa_memblock_release(u->memblock);
 
-    snprintf(t, sizeof(t), "Sine Generator at %u Hz", frequency);
+    pa_snprintf(t, sizeof(t), "Sine Generator at %u Hz", frequency);
 
     pa_sink_input_new_data_init(&data);
     data.sink = sink;
index 288e049e89863bfacb9f3d056959e662fbc4b80d..b96d46b31302997c17ed68ff8b343ed67289a0d5 100644 (file)
@@ -596,12 +596,12 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
     }
 
 #ifdef TUNNEL_SINK
-    snprintf(name, sizeof(name), "Tunnel from host %s, user %s, sink %s",
+    pa_snprintf(name, sizeof(name), "Tunnel from host %s, user %s, sink %s",
              pa_get_host_name(hn, sizeof(hn)),
              pa_get_user_name(un, sizeof(un)),
              u->sink->name);
 #else
-    snprintf(name, sizeof(name), "Tunnel from host %s, user %s, source %s",
+    pa_snprintf(name, sizeof(name), "Tunnel from host %s, user %s, source %s",
              pa_get_host_name(hn, sizeof(hn)),
              pa_get_user_name(un, sizeof(un)),
              u->source->name);
index ea2706e4243711c01d96b2cba3ead968dd828386..a35fe810ff51714e3f754a378f79bea0d3ac2cbc 100644 (file)
@@ -112,10 +112,10 @@ static void resolve_callback(
     assert(opcode >= 0);
 
     if (aa->proto == AVAHI_PROTO_INET)
-        snprintf(a, sizeof(a), "tcp:%s:%u", avahi_address_snprint(ip, sizeof(ip), aa), port);
+        pa_snprintf(a, sizeof(a), "tcp:%s:%u", avahi_address_snprint(ip, sizeof(ip), aa), port);
     else {
         assert(aa->proto == AVAHI_PROTO_INET6);
-        snprintf(a, sizeof(a), "tcp6:%s:%u", avahi_address_snprint(ip, sizeof(ip), aa), port);
+        pa_snprintf(a, sizeof(a), "tcp6:%s:%u", avahi_address_snprint(ip, sizeof(ip), aa), port);
     }
     i.server = a;
 
index d5b8f74377ef8b57fe3cf04edf3c2724f6b84839..5f1fa95ff1e923db4db07404a32af79ea55898fe 100644 (file)
@@ -370,7 +370,7 @@ char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map) {
     *(e = s) = 0;
 
     for (channel = 0; channel < map->channels && l > 1; channel++) {
-        l -= snprintf(e, l, "%s%s",
+        l -= pa_snprintf(e, l, "%s%s",
                       first ? "" : ",",
                       pa_channel_position_to_string(map->map[channel]));
 
index 58a5a8794fa3476b076b44af17f54b49e0108d86..0dba9051e9ea1d0ef6ee75e5ec509c73e7cfdd7b 100644 (file)
@@ -535,7 +535,7 @@ static int context_connect_spawn(pa_context *c) {
         argv[n++] = c->conf->daemon_binary;
         argv[n++] = "--daemonize=yes";
 
-        snprintf(t, sizeof(t), "-Lmodule-native-protocol-fd fd=%i", fds[1]);
+        pa_snprintf(t, sizeof(t), "-Lmodule-native-protocol-fd fd=%i", fds[1]);
         argv[n++] = strdup(t);
 
         while (n < MAX_ARGS) {
index ffdeedf75d91294f40e6d21780e2ff61f7dc2452..3d449f53bafcddac265c69dd468f5278550a8a1c 100644 (file)
@@ -31,6 +31,7 @@
 #include <math.h>
 #include <string.h>
 
+#include <pulsecore/core-util.h>
 #include "sample.h"
 
 size_t pa_sample_size(const pa_sample_spec *spec) {
@@ -117,22 +118,22 @@ char *pa_sample_spec_snprint(char *s, size_t l, const pa_sample_spec *spec) {
     assert(s && l && spec);
 
     if (!pa_sample_spec_valid(spec))
-        snprintf(s, l, "Invalid");
+        pa_snprintf(s, l, "Invalid");
     else
-        snprintf(s, l, "%s %uch %uHz", pa_sample_format_to_string(spec->format), spec->channels, spec->rate);
+        pa_snprintf(s, l, "%s %uch %uHz", pa_sample_format_to_string(spec->format), spec->channels, spec->rate);
 
     return s;
 }
 
 char* pa_bytes_snprint(char *s, size_t l, unsigned v) {
     if (v >= ((unsigned) 1024)*1024*1024)
-        snprintf(s, l, "%0.1f GiB", ((double) v)/1024/1024/1024);
+        pa_snprintf(s, l, "%0.1f GiB", ((double) v)/1024/1024/1024);
     else if (v >= ((unsigned) 1024)*1024)
-        snprintf(s, l, "%0.1f MiB", ((double) v)/1024/1024);
+        pa_snprintf(s, l, "%0.1f MiB", ((double) v)/1024/1024);
     else if (v >= (unsigned) 1024)
-        snprintf(s, l, "%0.1f KiB", ((double) v)/1024);
+        pa_snprintf(s, l, "%0.1f KiB", ((double) v)/1024);
     else
-        snprintf(s, l, "%u B", (unsigned) v);
+        pa_snprintf(s, l, "%u B", (unsigned) v);
 
     return s;
 }
index d561329cb70e9d25ccd628ddf41485df5e4268bd..c4f2cf7860ce0fbd724bd7377d914aecc4bfeabf 100644 (file)
@@ -90,7 +90,7 @@ char *pa_get_user_name(char *s, size_t l) {
             * that do not support getpwuid_r. */
         if ((r = getpwuid(getuid())) == NULL) {
 #endif
-            snprintf(s, l, "%lu", (unsigned long) getuid());
+            pa_snprintf(s, l, "%lu", (unsigned long) getuid());
             return s;
         }
 
index feb33f078b9340b584bdbe28dd2ea5e63be9b741..8bba834d5bd833e5ae35764c9b6e16a8d6b4734a 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <pulsecore/core-util.h>
 #include "volume.h"
 
 int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b) {
@@ -125,7 +126,7 @@ char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c) {
     *(e = s) = 0;
 
     for (channel = 0; channel < c->channels && l > 1; channel++) {
-        l -= snprintf(e, l, "%s%u: %3u%%",
+        l -= pa_snprintf(e, l, "%s%u: %3u%%",
                       first ? "" : " ",
                       channel,
                       (c->values[channel]*100)/PA_VOLUME_NORM);
index cb2727845dff287e003bc42f74ef6ff8fd268165..d5fe6f207c1f447b6c5726a8dcaf389696c05442 100644 (file)
@@ -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);
         }
     }
index 9879048403a01974605d798ab606ee3b1b0018ef..e61be704696bb0f7f494b43c4d9622eb8323006c 100644 (file)
@@ -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)));
     }
 
 
index 302369f78cb89736c43a9bdbef0997ee299149f8..041bc09bc38ef747b4aaaeea6f3c28489b7c8897 100644 (file)
@@ -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],
index 7f66af0595ec8caccb51a00d66d1a39d82685be0..5fae3fc37c5a08f7f064765eb69dc8beeb0c4a3b 100644 (file)
@@ -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;
index 10238acb058bb40a549318b1372fed1f7d31f8be..f5ec1c09b220105dbcc9b2e93de34c6ba772f825 100644 (file)
@@ -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);
 }
index 5e670e17afd53a145a34a1a5799525fea9af9201..efb6e64e14610b50231409ef9fc257fe933ef550 100644 (file)
@@ -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) {
index 6a5c61273c4a67de5038a5cdf8b20ee6af408f50..fe0b879bd9735bffef2f3fb6d9cf93b194b933c2 100644 (file)
@@ -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);
index 3541721aa4264d28a4ebc04cae05f07539514394..eb5bda0dbf6f4a5fdb134b87c540c5bbb316faca 100644 (file)
@@ -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"
index 864556930eeb3daa2d5e53da97d259ad357042db..97345f00a04a794ed9207786cc8f0d57f4c39649 100644 (file)
@@ -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);
index 8c7fb4db56bc59efb6f09ad2c46d195eae8f572a..8ef02f61b8a5686da71fe8b6758aef1fb82e1c55 100644 (file)
@@ -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;
 }
 
index b83bfeadf7c99c79411a8c15abb973c61cb0dacc..9e7280ddb619255c89ec2b5369fc18a53fac6ac6 100644 (file)
@@ -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);
index b5a6dc3177ba083a670ff3aba040cf70ca9d1013..c900ff3280d595433342fe02f59da9fde095cdfc 100644 (file)
@@ -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;
         }
 
index 05cb3369c5482c592596e6cdad40158ace91eedd..511f12efb298fe627456367436ed894abff239ed 100644 (file)
@@ -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) {
index a3ddc1144c3cae330722668ab68418cdd072d59c..2c66f5fa25605ffadd068ff526a759a5c1c1bde8 100644 (file)
@@ -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) {
index 6a6a26924f656b8dc73a096fddd3dcf3c0dbcaa4..067b7df06e95c54e3d8276987caf719c3e968ecd 100644 (file)
@@ -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);