2015-03-20 06:35:08

by Bharat Bhusan Panda

[permalink] [raw]
Subject: [PATCH ] obexd/pbap: Fix NULL check to avoid potential crash

NULL pointer check for name is done before using the same.
---
obexd/plugins/pbap.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c
index cec5acd..f2f9166 100644
--- a/obexd/plugins/pbap.c
+++ b/obexd/plugins/pbap.c
@@ -728,6 +728,11 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
int ret;
void *request;

+ if (name == NULL) {
+ ret = -EBADR;
+ goto fail;
+ }
+
DBG("name %s context %p valid %d", name, context, pbap->cache.valid);

if (oflag != O_RDONLY) {
@@ -735,11 +740,6 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
goto fail;
}

- if (name == NULL) {
- ret = -EBADR;
- goto fail;
- }
-
/* PullvCardListing always get the contacts from the cache */

if (pbap->cache.valid) {
--
1.9.1



2015-03-20 13:38:56

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH ] obexd/pbap: Fix NULL check to avoid potential crash

Hi Bharat,

On Fri, Mar 20, 2015 at 8:35 AM, Bharat Panda <[email protected]> wrote:
> NULL pointer check for name is done before using the same.
> ---
> obexd/plugins/pbap.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c
> index cec5acd..f2f9166 100644
> --- a/obexd/plugins/pbap.c
> +++ b/obexd/plugins/pbap.c
> @@ -728,6 +728,11 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
> int ret;
> void *request;
>
> + if (name == NULL) {
> + ret = -EBADR;
> + goto fail;
> + }
> +
> DBG("name %s context %p valid %d", name, context, pbap->cache.valid);
>
> if (oflag != O_RDONLY) {
> @@ -735,11 +740,6 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
> goto fail;
> }
>
> - if (name == NULL) {
> - ret = -EBADR;
> - goto fail;
> - }
> -
> /* PullvCardListing always get the contacts from the cache */
>
> if (pbap->cache.valid) {
> --
> 1.9.1

Applied, thanks.


--
Luiz Augusto von Dentz