Fix crash setting NULL name
PATCH 1/2 Fix crash setting NULL name
From: Andrei Emeltchenko <[email protected]>
set_name might be invoked with name argument as shown below:set_name(adapter, btd_adapter_get_name(adapter)) and btd_adapter_get_name may return NULL. Add check to prevent crash.
--- src/adapter.c | 3 +++ 1 file changed, 3 insertions(+)
src/adapter.c +3 -0
@@ -643,6 +643,9 @@ static int set_name(struct btd_adapter *adapter, const char *name)struct mgmt_cp_set_local_name cp;char maxname[MAX_NAME_LENGTH +1 ]; +if (name ==NULL ) +return -EINVAL ; +memset (maxname,0 ,sizeof (maxname));strncpy (maxname, name,MAX_NAME_LENGTH );
Signature · 1 line
1.8.1.2
PATCH 2/2 Change __FUNCTION__ to __func__
From: Andrei Emeltchenko <[email protected]>
checkpatch.pl recommends to use __func__ instead of __FUNCTION__.
--- attrib/gattrib.c | 2 +- gobex/gobex-debug.h | 2 +- obexd/src/log.h | 2 +- src/log.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
attrib/gattrib.c +1 -1
@@ -718,7 +718,7 @@ gboolean g_attrib_unregister(GAttrib *attrib, guint id)GSList *l;if (id ==0 ) { -warn ("%s: invalid id" , __FUNCTION__); +warn ("%s: invalid id" , __func__);return FALSE; }
gobex/gobex-debug.h +1 -1
@@ -40,7 +40,7 @@ extern guint gobex_debug;#define g_obex_debug (level, format, ...) \ if (gobex_debug & level) \ g_log("gobex", G_LOG_LEVEL_DEBUG, "%s:%s() " format, __FILE__, \ - __FUNCTION__, ## __VA_ARGS__) + __func__, ## __VA_ARGS__)static inline void g_obex_dump (guint level,const char *prefix,const void *buf,gsize len)
obexd/src/log.h +1 -1
@@ -52,5 +52,5 @@ struct obex_debug_desc { .file = __FILE__, .flags = OBEX_DEBUG_FLAG_DEFAULT, \ }; \if (__obex_debug_desc.flags &OBEX_DEBUG_FLAG_PRINT ) \ - obex_debug("%s:%s() " fmt, __FILE__, __FUNCTION__ , ## arg); \ + obex_debug("%s:%s() " fmt, __FILE__, __func__ , ## arg); \ }while (0 )
src/log.h +1 -1
@@ -55,5 +55,5 @@ void __btd_enable_debug(struct btd_debug_desc *start, .file = __FILE__, .flags = BTD_DEBUG_FLAG_DEFAULT, \ }; \if (__btd_debug_desc.flags &BTD_DEBUG_FLAG_PRINT ) \ - btd_debug("%s:%s() " fmt, __FILE__, __FUNCTION__ , ## arg); \ + btd_debug("%s:%s() " fmt, __FILE__, __func__ , ## arg); \ }while (0 )
Signature · 1 line
1.8.1.2
Re: [PATCH 2/2] Change __FUNCTION__ to __func__
Hi Andrei,
Quoted 7 lines · Andrei Emeltchenko
checkpatch.pl recommends to use
__func__instead of__FUNCTION__.--- attrib/gattrib.c | 2 +- gobex/gobex-debug.h | 2 +- obexd/src/log.h | 2 +- src/log.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
I've applied this patch with a more thorough explanation in the commit message.
Johan