diff --git a/daemon/cmd_save_studio.c b/daemon/cmd_save_studio.c index 2c2b2b37..afb56561 100644 --- a/daemon/cmd_save_studio.c +++ b/daemon/cmd_save_studio.c @@ -50,7 +50,7 @@ write_jack_parameter( { const char * src; char * dst; - char path[JACK_CONF_MAX_ADDRESS_SIZE * 3]; /* encode each char in three bytes (percent encoding) */ + char path[max_escaped_length(JACK_CONF_MAX_ADDRESS_SIZE)]; const char * content; char valbuf[100]; diff --git a/daemon/escape.h b/daemon/escape.h index 9cf55bbc..a18cfb98 100644 --- a/daemon/escape.h +++ b/daemon/escape.h @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2009 Nedko Arnaudov + * Copyright (C) 2009, 2010 Nedko Arnaudov * ************************************************************************** * This file contains the prototypes of the escape helper functions @@ -32,4 +32,7 @@ void escape(const char ** src_ptr, char ** dst_ptr); size_t unescape(const char * src, size_t src_len, char * dst); +/* encode each char in three bytes (percent encoding) */ +#define max_escaped_length(unescaped_length) ((unescaped_length) * 3) + #endif /* #ifndef ESCAPE_H__FABBE484_1093_41C1_9FC9_62ED0106E542__INCLUDED */ diff --git a/daemon/save.c b/daemon/save.c index a32b255f..16a1d53d 100644 --- a/daemon/save.c +++ b/daemon/save.c @@ -427,7 +427,7 @@ ladish_save_app( ret = false; - escaped_buffer = malloc(ladish_max(strlen(name), strlen(command)) * 3 + 1); /* encode each char in three bytes (percent encoding) */ + escaped_buffer = malloc(max_escaped_length(ladish_max(strlen(name), strlen(command))) + 1); if (escaped_buffer == NULL) { log_error("malloc() failed.");