given the following
when the function is called, it runs ok on sparc machine but segment faults on amd i386 both running Solaris 10Code:typedef struct { char fileName[ 1024]; time_t deleteTime; } file_item_t; .... .... setFileEntry( char *fileName) { file_item_t file; memset( &file, 0x00, sizeof( file_item_t )); memcpy( file.fileName, fileName, sizeof( file.fileName ) - 1 ); ... ...
fileName is a null term string.
While it copies more data than is required, the destination buf is sufficent to hold it.
So not sure why there would be a problem on that point.
if I replace the memcpy with a strcpy the bug is removed.
or if replace the sizeof with strlen+1, it works ok too.
is it possible that memcpy behaves differently on the different architectures?




Reply With Quote