mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-03-21 20:51:27 +00:00
libsysprof-capture: Use vsnprintf() instead of g_strdup_printf()
This imposes an arbitrary limit of 2048B on the length of printf-ed log messages, but is otherwise equivalent. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #40
This commit is contained in:
@ -65,7 +65,9 @@
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
# include <sched.h>
|
# include <sched.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
@ -466,14 +468,14 @@ sysprof_collector_log_printf (int severity,
|
|||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
COLLECTOR_BEGIN {
|
COLLECTOR_BEGIN {
|
||||||
g_autofree char *formatted = NULL;
|
char formatted[2048];
|
||||||
SysprofCaptureLog *ev;
|
SysprofCaptureLog *ev;
|
||||||
va_list args;
|
va_list args;
|
||||||
size_t len;
|
size_t len;
|
||||||
size_t sl;
|
size_t sl;
|
||||||
|
|
||||||
va_start (args, format);
|
va_start (args, format);
|
||||||
formatted = g_strdup_vprintf (format, args);
|
vsnprintf (formatted, sizeof (formatted), format, args);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
if (domain == NULL)
|
if (domain == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user