summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/core-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-07-25 16:23:03 +0000
committerLennart Poettering <lennart@poettering.net>2007-07-25 16:23:03 +0000
commit929526de33b60ba48e47071be60619616661c97f (patch)
tree581112fa58632254fc22c69893605fa6d1b815e1 /src/pulsecore/core-util.c
parent8e838381541d090b5bfd0d68acefd2d6676f0d64 (diff)
Convert most snprintf() calls to pa_snprintf()
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1534 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/core-util.c')
-rw-r--r--src/pulsecore/core-util.c17
1 files changed, 10 insertions, 7 deletions
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)));
}