[rhythmbox] refstring: use g_strlcpy to avoid glibc braindamage
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] refstring: use g_strlcpy to avoid glibc braindamage
- Date: Sun, 25 Mar 2012 21:29:13 +0000 (UTC)
commit dae9cb13a7bda14c6f1f4a1ba11fc02ef58b79e2
Author: Jonathan Matthew <jonathan d14n org>
Date: Sun Mar 25 22:05:41 2012 +1000
refstring: use g_strlcpy to avoid glibc braindamage
Certain versions of glibc have a broken SSE strcpy that writes
past the end of the destination. This only seems to cause
problems on i386, where it results in random heap corruption
during startup, usually followed by crashes. x86_64 seems to
be unaffected, probably due to a combination of malloc and
structure member alignment.
In comparison, (g_)strlcpy is a simple for loop, so it doesn't
crash.
I'm sure the optimised strcpy looks nice in benchmarks though.
https://bugzilla.gnome.org/show_bug.cgi?id=666066
rhythmdb/rb-refstring.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/rhythmdb/rb-refstring.c b/rhythmdb/rb-refstring.c
index 6e18ed2..5a05d78 100644
--- a/rhythmdb/rb-refstring.c
+++ b/rhythmdb/rb-refstring.c
@@ -95,7 +95,7 @@ rb_refstring_new (const char *init)
ret = g_malloc (sizeof (RBRefString) + strlen (init));
- strcpy (ret->value, init);
+ g_strlcpy (ret->value, init, strlen (init) + 1);
g_atomic_int_set (&ret->refcount, 1);
ret->folded = NULL;
ret->sortkey = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]