Return-Path: Message-ID: From: Robert Wlaschin To: "'bluez-devel@lists.sourceforge.net'" Subject: RE: [Bluez-devel] textfile.c find_key MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C5E49A.8A2DA1B0" Sender: bluez-devel-admin@lists.sourceforge.net Errors-To: bluez-devel-admin@lists.sourceforge.net Reply-To: bluez-devel@lists.sourceforge.net List-Unsubscribe: , List-Id: BlueZ development List-Post: List-Help: List-Subscribe: , List-Archive: Date: Tue, 8 Nov 2005 11:28:04 -0800 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C5E49A.8A2DA1B0 Content-Type: text/plain; charset="iso-8859-1" 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:marcel@holtmann.org] Sent: Tuesday, November 08, 2005 10:17 AM To: bluez-devel@lists.sourceforge.net 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 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 Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ------_=_NextPart_001_01C5E49A.8A2DA1B0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 =3D = strstr(map, key);
+       char *off =3D = NULL;
+
+       if(map)
+       {
+          &n= bsp;    off =3D strstr(map, key);
 
          &nb= sp;     while (off && ((off > map = && *(off - 1) !=3D '\r' &&
          &nb= sp;           &nb= sp;        *(off - 1) !=3D '\n') || = *(off + len) !=3D ' '))
          &nb= sp;     off =3D strstr(off + len, key);
+       }
 
        return = off;
 }

Thanks,
Robert

-----Original Message-----
From: Marcel Holtmann [mailto:marcel@holtmann.org]
Sent: Tuesday, November 08, 2005 10:17 AM
To: bluez-devel@lists.sourceforge.net
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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-dev= el

------_=_NextPart_001_01C5E49A.8A2DA1B0-- ------------------------------------------------------- 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 Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel