2005-11-08 19:28:04

by Robert Wlaschin

[permalink] [raw]
Subject: RE: [Bluez-devel] textfile.c find_key

Marcel,

Not sure if you are interested in this but in the file textfile.c, function
find_key. If map is ever NULL the strstr will segment fault. An instance
of this happening would be when the key file was empty. This might happen
if a Linux Op was removing keys that were invalidated by a lost pairing. I
feel that in general checking for a NULL is better than not.

Here's a patch ...

--- ./bluez-utils-2.21/common/textfile.c 2005-09-10
05:27:26.000000000 -0700
+++ ./bluez-utils-2.21-orig/common/textfile.c 2005-11-08
11:18:09.837262992 -0800
@@ -115,11 +115,16 @@

static inline char *find_key(char *map, char *key, size_t len)
{
- char *off = strstr(map, key);
+ char *off = NULL;
+
+ if(map)
+ {
+ off = strstr(map, key);

while (off && ((off > map && *(off - 1) != '\r' &&
*(off - 1) != '\n') || *(off + len) != ' '))
off = strstr(off + len, key);
+ }

return off;
}

Thanks,
Robert

-----Original Message-----
From: Marcel Holtmann [mailto:[email protected]]
Sent: Tuesday, November 08, 2005 10:17 AM
To: [email protected]
Subject: Re: [Bluez-devel] C Program for Getting Link Quality


Hi Arpit,

> I did a yum update bluez*.
>
> The verion I'm using is:
>
> [root@174-15 bluetooth]# ls -l
> total 116
> -rw-r--r-- 1 root root 3607 Mar 2 2005 bluetooth.h
>
> On including sys/socket.h..the error is the same:

maybe <sys/ioctl.h> is also missing.

Regards

Marcel




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2005-11-08 19:55:20

by Marcel Holtmann

[permalink] [raw]
Subject: RE: [Bluez-devel] textfile.c find_key

Hi Robert,

> Not sure if you are interested in this but in the file textfile.c,
> function find_key. If map is ever NULL the strstr will segment fault.
> An instance of this happening would be when the key file was empty.
> This might happen if a Linux Op was removing keys that were
> invalidated by a lost pairing. I feel that in general checking for a
> NULL is better than not.

how can map be NULL? Check "man mmap" about the return value of mmap().

Regards

Marcel




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel