After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 629449 - soup_message_new segfault
soup_message_new segfault
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: Misc
2.31.x
Other Linux
: Normal major
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
: 600238 629286 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-09-12 19:21 UTC by Adrian Bunk
Modified: 2010-12-20 14:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix a crash when resolving URIs with both spaces and non-UTF8 chars (1.54 KB, patch)
2010-09-13 14:41 UTC, Dan Winship
committed Details | Review

Description Adrian Bunk 2010-09-12 19:21:15 UTC
A segfault a user reported in Liferea boils down to a segfault of the following libsoup call (tested with 2.31.6):

soup_message_new (SOUP_METHOD_GET, "\366i http://");


Backtrace:

Program received signal SIGSEGV, Segmentation fault.
__strchr_sse42 () at ../sysdeps/x86_64/multiarch/strchr.S:131
131     ../sysdeps/x86_64/multiarch/strchr.S: No such file or directory.
        in ../sysdeps/x86_64/multiarch/strchr.S
(gdb) bt
  • #0 __strchr_sse42
    at ../sysdeps/x86_64/multiarch/strchr.S line 131
  • #1 uri_normalized_copy
    at soup-uri.c line 690
  • #2 soup_uri_new_with_base
    at soup-uri.c line 269
  • #3 soup_uri_new
    at soup-uri.c line 401
  • #4 soup_message_new
    at soup-message.c line 762

Comment 1 Dan Winship 2010-09-12 21:40:23 UTC
worksforme. (Well, I get "Could not parse '�i http://' as a URL", but it doesn't crash. Or even make valgrind complain.)

What distro are you on, what gcc version and compiler flags were used to build libsoup, and what glibc version do you have?
Comment 2 Adrian Bunk 2010-09-12 21:57:31 UTC
Debian unstable, I also have the same issue with the 2.30.2-1 package
gcc 4.4
eglibc 2.11.2

Valgrind says (with 2.30.2):
==24776== Invalid read of size 1
==24776==    at 0x4C25361: __GI_strchr (mc_replace_strmem.c:144)
==24776==    by 0x71A56AB: uri_normalized_copy (soup-uri.c:690)
==24776==    by 0x71A66B9: soup_uri_new_with_base (soup-uri.c:269)
==24776==    by 0x71A6F31: soup_uri_new (soup-uri.c:401)
==24776==    by 0x7193F7A: soup_message_new (soup-message.c:700)
...
==24776==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
Comment 3 Adrian Bunk 2010-09-12 23:19:52 UTC
Dan, are you using a non-UTF-8 locale?

Then http://library.gnome.org/devel/glib/unstable/glib-String-Utility-Functions.html#string-precision might explain it.


                while ((sp = strchr (normalized, ' '))) {
                        tmp = g_strdup_printf ("%.*s%%20%s",
                                               (int)(sp - normalized),
                                               normalized, sp + 1);
                        g_free (normalized);
                        normalized = tmp;
                };


I checked what exactly happenens here, and tmp is NULL after the first call to g_strdup_printf(), and the next strchr() call is the failing one.
Comment 4 Dan Winship 2010-09-13 04:30:08 UTC
no, i'm using en_US.UTF-8... but... wow. That "feature" of glibc is pretty moronic.
Comment 5 Dan Winship 2010-09-13 14:41:03 UTC
Created attachment 170158 [details] [review]
Fix a crash when resolving URIs with both spaces and non-UTF8 chars

I still can't reproduce it. Does this fix it for you?

The glibc maintainers say C99 requires this behavior
(http://sources.redhat.com/bugzilla/show_bug.cgi?id=649#c1) but I don't
see how. The description of "%s" does mix "byte" and "character"
confusingly, but it also says in a footnote that "no special provisions
are made for multibyte characters".
Comment 6 Adrian Bunk 2010-09-13 18:34:22 UTC
(In reply to comment #5)
> Created an attachment (id=170158) [details] [review]
> Fix a crash when resolving URIs with both spaces and non-UTF8 chars
> 
> I still can't reproduce it. Does this fix it for you?

Thanks, that fixes it for me.
Comment 7 Dan Winship 2010-09-13 19:43:11 UTC
Attachment 170158 [details] pushed as 318dae5 - Fix a crash when resolving URIs with both spaces and non-UTF8 chars
Comment 8 Dan Winship 2010-09-13 19:44:00 UTC
*** Bug 629286 has been marked as a duplicate of this bug. ***
Comment 9 Dan Winship 2010-12-20 14:03:33 UTC
*** Bug 600238 has been marked as a duplicate of this bug. ***