bug in optimised strstr

Sam Clegg sam@ideaworks3d.com
Thu Oct 2 16:46:00 GMT 2008


I think there is bug in the current strstr implementation.  I initially
found this in the codesourcery distribution and have recently reproduced
it using newlib form CVS on both arm and x86 platforms.  Here is the
repro case:

    const char* s1 = "GL_OES_byte_coordinates GL_OES_compressed_paletted_texture GL_OES_fixed_point GL_OES_point_size_array GL_OES_point_sprite GL_OES_read_format GL_OES_single_precision GL_IMG_texture_compression_pvrtc GL_IMG_texture_env_enhanced_fixed_function GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_IMG_user_clip_planes GL_OES_matrix_get GL_IMG_vertex_program GL_EXT_multi_draw_arrays GL_OES_matrix_palette GL_OES_draw_texture ";
    const char* s2 = "GL_IMG_texture_compression_pvrtc";
    const char* res = strstr(s1, s2);  // crash in critical_factorization

This bug seems to have been in newlib for a long time.  It can be worked
around by compiling with -Os and thereby disabling the strstr
optimisations.

-- 
sam clegg
sam@ideaworks3d.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://sourceware.org/pipermail/newlib/attachments/20081002/29e3b25e/attachment.sig>


More information about the Newlib mailing list