All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] gdbus: Use g_dbus_create_error_valist internally
@ 2015-04-07 20:10 Szymon Janc
  2015-04-07 20:10 ` [PATCH 2/2] gdbus: Fix crash in g_dbus_create_error_valist Szymon Janc
  2015-04-09 14:39 ` [PATCH 1/2] gdbus: Use g_dbus_create_error_valist internally Szymon Janc
  0 siblings, 2 replies; 3+ messages in thread
From: Szymon Janc @ 2015-04-07 20:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

There is no need to duplicate code in g_dbus_send_error_valist.
---
 gdbus/object.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/gdbus/object.c b/gdbus/object.c
index 4d5a64c..c3c137b 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1530,11 +1530,8 @@ gboolean g_dbus_send_error_valist(DBusConnection *connection,
 					const char *format, va_list args)
 {
 	DBusMessage *error;
-	char str[1024];
-
-	vsnprintf(str, sizeof(str), format, args);
 
-	error = dbus_message_new_error(message, name, str);
+	error = g_dbus_create_error_valist(message, name, format, args);
 	if (error == NULL)
 		return FALSE;
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] gdbus: Fix crash in g_dbus_create_error_valist
  2015-04-07 20:10 [PATCH 1/2] gdbus: Use g_dbus_create_error_valist internally Szymon Janc
@ 2015-04-07 20:10 ` Szymon Janc
  2015-04-09 14:39 ` [PATCH 1/2] gdbus: Use g_dbus_create_error_valist internally Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2015-04-07 20:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Passing NULL format parameter to vsnprintf results in invalid argument
error on glibc. But with some other libc libraries (musl and uClibc)
this results in dereferencing NULL pointer and crash due to
segmentation fault.
---
 gdbus/object.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdbus/object.c b/gdbus/object.c
index c3c137b..74e975b 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1412,7 +1412,10 @@ DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name,
 {
 	char str[1024];
 
-	vsnprintf(str, sizeof(str), format, args);
+	if (format)
+		vsnprintf(str, sizeof(str), format, args);
+	else
+		str[0] = '\0';
 
 	return dbus_message_new_error(message, name, str);
 }
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] gdbus: Use g_dbus_create_error_valist internally
  2015-04-07 20:10 [PATCH 1/2] gdbus: Use g_dbus_create_error_valist internally Szymon Janc
  2015-04-07 20:10 ` [PATCH 2/2] gdbus: Fix crash in g_dbus_create_error_valist Szymon Janc
@ 2015-04-09 14:39 ` Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2015-04-09 14:39 UTC (permalink / raw)
  To: linux-bluetooth

On Tuesday 07 of April 2015 22:10:48 Szymon Janc wrote:
> There is no need to duplicate code in g_dbus_send_error_valist.
> ---
>  gdbus/object.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/gdbus/object.c b/gdbus/object.c
> index 4d5a64c..c3c137b 100644
> --- a/gdbus/object.c
> +++ b/gdbus/object.c
> @@ -1530,11 +1530,8 @@ gboolean g_dbus_send_error_valist(DBusConnection
> *connection, const char *format, va_list args)
>  {
>  	DBusMessage *error;
> -	char str[1024];
> -
> -	vsnprintf(str, sizeof(str), format, args);
> 
> -	error = dbus_message_new_error(message, name, str);
> +	error = g_dbus_create_error_valist(message, name, format, args);
>  	if (error == NULL)
>  		return FALSE;

Applied.

-- 
BR
Szymon Janc

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-09 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 20:10 [PATCH 1/2] gdbus: Use g_dbus_create_error_valist internally Szymon Janc
2015-04-07 20:10 ` [PATCH 2/2] gdbus: Fix crash in g_dbus_create_error_valist Szymon Janc
2015-04-09 14:39 ` [PATCH 1/2] gdbus: Use g_dbus_create_error_valist internally Szymon Janc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.