[asalkeld/libqb] c60f50: ipcs: avoid use-after-free for size-0 || disconnec...
by Jim Meyering
Branch: refs/heads/master
Home: https://github.com/asalkeld/libqb
Commit: c60f5012ead3afe0250059a9886db23e3b4e12fd
https://github.com/asalkeld/libqb/commit/c60f5012ead3afe0250059a9886db23e...
Author: Jim Meyering <jim(a)meyering.net>
Date: 2012-07-18 (Wed, 18 Jul 2012)
Changed paths:
M lib/ipcs.c
Log Message:
-----------
ipcs: avoid use-after-free for size-0 || disconnect-request
Hi,
Glancing through coverity-reported issues,
I saw that this one required attention:
>From 70f1f689022321710405f16dc45b3df30c22bc59 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 18 Jul 2012 17:34:17 +0200
Subject: [PATCH] ipcs: avoid use-after-free for size-0 || disconnect-request
spotted by coverity:
http://libqb.org/html/0.14.1/coverity/1/265ipcs.c.html#error
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Commit: 2ada241eee8501ab200c6d8de7081d02011d0436
https://github.com/asalkeld/libqb/commit/2ada241eee8501ab200c6d8de7081d02...
Author: Jim Meyering <jim(a)meyering.net>
Date: 2012-07-18 (Wed, 18 Jul 2012)
Changed paths:
M tests/rbwriter.c
Log Message:
-----------
tests/rbwriter: don't ignore write failure
Here's another fix.
In adjusting the printf, I added a cast and switched to %5ld.
I would have preferred to use %5jd as the printf format (i.e., then no
cast is needed), but saw no other uses of the "j" directive, so perhaps
you do not yet depend on printf with such support.
>From 6d5d3af35d1f6851537f7af8996d1106c1ebe435 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 18 Jul 2012 17:54:38 +0200
Subject: [PATCH] tests/rbwriter: don't ignore write failure
Spotted by coverity:
This less-than-zero comparison of an unsigned value is never true.
"res < 0U".
http://libqb.org/html/0.14.1/coverity/1/7rbwriter.c.html#error
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Compare: https://github.com/asalkeld/libqb/compare/5470bf562535...2ada241eee85
11 years, 8 months
[PATCH] tests/rbwriter: don't ignore write failure
by Jim Meyering
Here's another fix.
In adjusting the printf, I added a cast and switched to %5ld.
I would have preferred to use %5jd as the printf format (i.e., then no
cast is needed), but saw no other uses of the "j" directive, so perhaps
you do not yet depend on printf with such support.
>From 6d5d3af35d1f6851537f7af8996d1106c1ebe435 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 18 Jul 2012 17:54:38 +0200
Subject: [PATCH] tests/rbwriter: don't ignore write failure
Spotted by coverity:
This less-than-zero comparison of an unsigned value is never true.
"res < 0U".
http://libqb.org/html/0.14.1/coverity/1/7rbwriter.c.html#error
---
tests/rbwriter.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/rbwriter.c b/tests/rbwriter.c
index 616a6c1..5d0cf5f 100644
--- a/tests/rbwriter.c
+++ b/tests/rbwriter.c
@@ -65,10 +65,10 @@ static void sigterm_handler(int32_t num)
}
static void
-_benchmark(int write_size)
+_benchmark(ssize_t write_size)
{
struct timeval tv1, tv2, tv_elapsed;
- unsigned int res;
+ ssize_t res;
int write_count = 0;
alarm_notice = 0;
@@ -89,7 +89,7 @@ _benchmark(int write_size)
timersub (&tv2, &tv1, &tv_elapsed);
printf ("%5d messages sent ", write_count);
- printf ("%5d bytes per write ", write_size);
+ printf ("%5ld bytes per write ", (long int) write_size);
printf ("%7.3f Seconds runtime ",
(tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)));
printf ("%9.3f TP/s ",
--
1.7.11.2.194.g7bdb748
11 years, 8 months
[PATCH] ipcs: avoid use-after-free for size-0 || disconnect-request
by Jim Meyering
Hi,
Glancing through coverity-reported issues,
I saw that this one required attention:
>From 70f1f689022321710405f16dc45b3df30c22bc59 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 18 Jul 2012 17:34:17 +0200
Subject: [PATCH] ipcs: avoid use-after-free for size-0 || disconnect-request
spotted by coverity:
http://libqb.org/html/0.14.1/coverity/1/265ipcs.c.html#error
---
lib/ipcs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/ipcs.c b/lib/ipcs.c
index eb23e79..95b7741 100644
--- a/lib/ipcs.c
+++ b/lib/ipcs.c
@@ -652,6 +652,7 @@ _process_request_(struct qb_ipcs_connection *c, int32_t ms_timeout)
qb_util_log(LOG_DEBUG, "client requesting a disconnect (%s)",
c->description);
qb_ipcs_disconnect(c);
+ c = NULL;
res = -ESHUTDOWN;
} else {
c->stats.requests++;
@@ -664,7 +665,7 @@ _process_request_(struct qb_ipcs_connection *c, int32_t ms_timeout)
}
}
- if (c->service->funcs.peek && c->service->funcs.reclaim) {
+ if (c && c->service->funcs.peek && c->service->funcs.reclaim) {
c->service->funcs.reclaim(&c->request);
}
--
1.7.11.2.194.g7bdb748
11 years, 8 months
[asalkeld/libqb] 3b3102: IPC: use calloc instead of malloc to fix valgrind ...
by Angus Salkeld
Branch: refs/heads/master
Home: https://github.com/asalkeld/libqb
Commit: 3b31023d84b0eff3f73dfb0547f91d4eb9c446ac
https://github.com/asalkeld/libqb/commit/3b31023d84b0eff3f73dfb0547f91d4e...
Author: Angus Salkeld <asalkeld(a)redhat.com>
Date: 2012-07-16 (Mon, 16 Jul 2012)
Changed paths:
M lib/ipc_us.c
M lib/ipcc.c
Log Message:
-----------
IPC: use calloc instead of malloc to fix valgrind warnings
This is to cleanup some valgrind warnings.
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Commit: 121abe3dbe136b86758baa30e7e73ac34e9fd47b
https://github.com/asalkeld/libqb/commit/121abe3dbe136b86758baa30e7e73ac3...
Author: Angus Salkeld <asalkeld(a)redhat.com>
Date: 2012-07-16 (Mon, 16 Jul 2012)
Changed paths:
M lib/ringbuffer.c
Log Message:
-----------
RB: use internal reclaim function
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Commit: deddaea86c8563eb21bb3792b22b8ea531692a18
https://github.com/asalkeld/libqb/commit/deddaea86c8563eb21bb3792b22b8ea5...
Author: Angus Salkeld <asalkeld(a)redhat.com>
Date: 2012-07-16 (Mon, 16 Jul 2012)
Changed paths:
M lib/ipc_shm.c
Log Message:
-----------
RB: convert the rb_peek() status into a recv like status.
peek returns 0 on no data, so convert that to -EAGAIN.
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Commit: bdc63cdf1aa317c698251fd0a23e081c86a57404
https://github.com/asalkeld/libqb/commit/bdc63cdf1aa317c698251fd0a23e081c...
Author: Angus Salkeld <asalkeld(a)redhat.com>
Date: 2012-07-16 (Mon, 16 Jul 2012)
Changed paths:
M lib/ringbuffer.c
Log Message:
-----------
RB: if read or peek don't get the message then re-post to the semaphore
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Commit: 6e1d9054c330cdc2fa7baabf56cbeea3a05db014
https://github.com/asalkeld/libqb/commit/6e1d9054c330cdc2fa7baabf56cbeea3...
Author: Angus Salkeld <asalkeld(a)redhat.com>
Date: 2012-07-16 (Mon, 16 Jul 2012)
Changed paths:
M lib/ringbuffer.c
Log Message:
-----------
RB: use sem_getvalue as a tie breaker when read_pt == write_pt
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Commit: 15d0291a8a148edc42b064acbe17699731b2cf42
https://github.com/asalkeld/libqb/commit/15d0291a8a148edc42b064acbe176997...
Author: Angus Salkeld <asalkeld(a)redhat.com>
Date: 2012-07-16 (Mon, 16 Jul 2012)
Changed paths:
M lib/ringbuffer.c
Log Message:
-----------
RB: cleanup the macros for wrapping the index
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Commit: b9a992a5d3f70f8be86f1bbcf81f209f5a2e5ba9
https://github.com/asalkeld/libqb/commit/b9a992a5d3f70f8be86f1bbcf81f209f...
Author: Angus Salkeld <asalkeld(a)redhat.com>
Date: 2012-07-17 (Tue, 17 Jul 2012)
Changed paths:
M lib/ringbuffer.c
Log Message:
-----------
RB: be more explicit about the word alignment
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Commit: 3feb3b6b8ff373ac02852432a89461946b10528e
https://github.com/asalkeld/libqb/commit/3feb3b6b8ff373ac02852432a8946194...
Author: Angus Salkeld <asalkeld(a)redhat.com>
Date: 2012-07-17 (Tue, 17 Jul 2012)
Changed paths:
M lib/ringbuffer.c
Log Message:
-----------
RB: improve the debug print outs
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Commit: e5be0396a7510d24b7e5e7a315c7f2f955e31452
https://github.com/asalkeld/libqb/commit/e5be0396a7510d24b7e5e7a315c7f2f9...
Author: Angus Salkeld <asalkeld(a)redhat.com>
Date: 2012-07-17 (Tue, 17 Jul 2012)
Changed paths:
M lib/ringbuffer.c
Log Message:
-----------
RB: set the new read pointer after clearing the header.
This is to prevent a situation where a fast writer will
write their new chunk between setting the new read pointer
and clearing the header.
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
Compare: https://github.com/asalkeld/libqb/compare/59bdedf59bee...e5be0396a751
11 years, 8 months