Wind River Support Network

HomeDefectsLIN6-3292
Fixed

LIN6-3292 : strstr is not working as expected

Created: Jan 31, 2013    Updated: Mar 10, 2016
Resolved Date: Dec 3, 2013
Previous ID: LIN5-3620, LIN6-2765
Found In Version: 6.0
Fix Version: 6.0
Severity: Severe
Applicable for: Wind River Linux 6
Component/s: Toolchain
Architecture: PowerPC

Description

The strstr() does not work as expected (at least on PPC boards)

With a simple testcase like this
#include <stdio.h>
#include <string.h>

const char *aa = "aaaaaaint";
const char *bb = "txxxxint";

int main(int argc,char *argv[]){
  char *p = strstr(aa,bb);
  printf("%s=strstr(\"%s\",\"%s\")\n",p,aa,bb);
  return 0;
}

The program should display:
     (null)=strstr("aaaaaaint","txxxxint")
But in reality it displays:
     txxxxint=strstr("aaaaaaint","txxxxint")

It seems that it's this bug:
http://sourceware.org/bugzilla/show_bug.cgi?id=14602

And the solution here:
http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=57e605ba50a42e1e5adc0f020f3752e80f117c10

Steps to Reproduce

Compile and test a simple testcase like this on target:

#include <stdio.h>
#include <string.h>

const char *aa = "aaaaaaint";
const char *bb = "txxxxint";

int main(int argc,char *argv[]){
  char *p = strstr(aa,bb);
  printf("%s=strstr(\"%s\",\"%s\")\n",p,aa,bb);
  return 0;
}
Live chat
Online