* [Bluez-devel] [PATCH] Properly replace an existing key value pair in a text file
@ 2005-09-07 11:17 Ville Nuorvala
2005-09-07 11:57 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Ville Nuorvala @ 2005-09-07 11:17 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 1191 bytes --]
Hi,
textfile_put() was unable to replace a key value pair if it happened to
be the last entry in a file. I noticed this problem in bluez-utils-2.19,
but it still seems to exist in the latest CVS code. The patch below
should fix it...
Index: common/textfile.c
===================================================================
RCS file: /cvsroot/bluez/utils/common/textfile.c,v
retrieving revision 1.6
diff -u -r1.6 textfile.c
--- common/textfile.c 30 Aug 2005 00:35:39 -0000 1.6
+++ common/textfile.c 7 Sep 2005 11:06:43 -0000
@@ -180,8 +180,14 @@
end += len;
len = size - (end - map);
-
- if (len <= 0 || len > size) {
+ if (!len) {
+ munmap(map, size);
+ ftruncate(fd, base);
+ pos = lseek(fd, base, SEEK_SET);
+ err = write_key_value(fd, key, value);
+ goto unlock;
+ }
+ if (len < 0 || len > size) {
err = EILSEQ;
goto unmap;
}
Regards,
Ville
--
Ville Nuorvala
Research Assistant,
Laboratory for Theoretical Computer Science,
Helsinki University of Technology
email: vnuorval@tcs.hut.fi, phone: +358 (0)9 451 5257
[-- Attachment #2: vnuorval.vcf --]
[-- Type: text/x-vcard, Size: 248 bytes --]
begin:vcard
fn:Ville Nuorvala
n:Nuorvala;Ville
adr:;;Helsinginkatu 17 A 18;Helsinki;;FIN-00500;Finland
email;internet:vnuorval@tcs.hut.fi
tel;work:+35894515257
tel;fax:+35894513369
tel;cell:+358405835323
x-mozilla-html:FALSE
version:2.1
end:vcard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bluez-devel] [PATCH] Properly replace an existing key value pair in a text file
2005-09-07 11:17 [Bluez-devel] [PATCH] Properly replace an existing key value pair in a text file Ville Nuorvala
@ 2005-09-07 11:57 ` Marcel Holtmann
2005-09-07 16:04 ` Ville Nuorvala
0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2005-09-07 11:57 UTC (permalink / raw)
To: bluez-devel
Hi Ville,
> textfile_put() was unable to replace a key value pair if it happened to
> be the last entry in a file. I noticed this problem in bluez-utils-2.19,
> but it still seems to exist in the latest CVS code. The patch below
> should fix it...
I though that I fixed this. Are you sure that problem is still present?
Regards
Marcel
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bluez-devel] [PATCH] Properly replace an existing key value pair in a text file
2005-09-07 11:57 ` Marcel Holtmann
@ 2005-09-07 16:04 ` Ville Nuorvala
2005-09-07 17:33 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Ville Nuorvala @ 2005-09-07 16:04 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 1163 bytes --]
Marcel Holtmann wrote:
> Hi Ville,
>
>
>>textfile_put() was unable to replace a key value pair if it happened to
>>be the last entry in a file. I noticed this problem in bluez-utils-2.19,
>>but it still seems to exist in the latest CVS code. The patch below
>>should fix it...
>
>
> I though that I fixed this. Are you sure that problem is still present?
Yes. I located the problem in Gentoo's bluez-utils-2.19 and since it
hasn't yet been fixed in the CVS repository, I'm quite certain it still
is present ;-)
I noticed the problem when hcid just wouldn't update the link key in
var/lib/bluetooth/<hwaddr>/linkkeys, even though the debug statements
claimed otherwise. The textfile_put() function clearly works incorrectly
since zero is a valid value for the len variable, but the if (len <= 0
|| ..) check causes the the function to exit before anything is written.
Btw, I resend the patch as a separate attachement since the tabs got
screwed up last time.
Regards,
Ville
--
Ville Nuorvala
Research Assistant,
Laboratory for Theoretical Computer Science,
Helsinki University of Technology
email: vnuorval@tcs.hut.fi, phone: +358 (0)9 451 5257
[-- Attachment #2: replace_key_value.patch --]
[-- Type: text/x-patch, Size: 618 bytes --]
Index: common/textfile.c
===================================================================
RCS file: /cvsroot/bluez/utils/common/textfile.c,v
retrieving revision 1.6
diff -u -r1.6 textfile.c
--- common/textfile.c 30 Aug 2005 00:35:39 -0000 1.6
+++ common/textfile.c 7 Sep 2005 11:06:43 -0000
@@ -180,8 +180,14 @@
end += len;
len = size - (end - map);
-
- if (len <= 0 || len > size) {
+ if (!len) {
+ munmap(map, size);
+ ftruncate(fd, base);
+ pos = lseek(fd, base, SEEK_SET);
+ err = write_key_value(fd, key, value);
+ goto unlock;
+ }
+ if (len < 0 || len > size) {
err = EILSEQ;
goto unmap;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bluez-devel] [PATCH] Properly replace an existing key value pair in a text file
2005-09-07 16:04 ` Ville Nuorvala
@ 2005-09-07 17:33 ` Marcel Holtmann
0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2005-09-07 17:33 UTC (permalink / raw)
To: bluez-devel
Hi Ville,
> Yes. I located the problem in Gentoo's bluez-utils-2.19 and since it
> hasn't yet been fixed in the CVS repository, I'm quite certain it still
> is present ;-)
>
> I noticed the problem when hcid just wouldn't update the link key in
> var/lib/bluetooth/<hwaddr>/linkkeys, even though the debug statements
> claimed otherwise. The textfile_put() function clearly works incorrectly
> since zero is a valid value for the len variable, but the if (len <= 0
> || ..) check causes the the function to exit before anything is written.
this sounds plausible. Your patch is applied to the CVS. Thanks.
Regards
Marcel
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-09-07 17:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-07 11:17 [Bluez-devel] [PATCH] Properly replace an existing key value pair in a text file Ville Nuorvala
2005-09-07 11:57 ` Marcel Holtmann
2005-09-07 16:04 ` Ville Nuorvala
2005-09-07 17:33 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).