Sun x86 Systems (MOSC)

MOSC Banner

strcpy problem overlapping source and destination in 64 bit ( sun_solaris_x64 )

edited Apr 18, 2013 12:24PM in Sun x86 Systems (MOSC) 7 commentsAnswered
A simple program like the following when compiled for 64 bit, it gives wrong result in some of the 64bit m/c.

/* a.c */
#include <stdio.h>
#include <string.h>
int main()
{
char st[50];
char *p = st + 2;
strcpy(st,"XY1234");
strcpy(st,p);
printf("\n%s\n",st);
return 0;
}

cc -o check_copy -m64 a.c

On running check_copy, the expected answer is "1234", but in some m/c this gives "1434" .

The libc.so.1 in both the m/cs are different.

The result is correct in older SunOS.
uname -a in two m/cs ( old_mc and new_mc )
SunOS old_mc 5.10 Generic_127112-05 i86pc i386 i86pc [ Gives correct result ]

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center