CA fails on big-endian host
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Fix Released
|
High
|
Jeff Hill |
Bug Description
From Yevgeny A. Gusev,
ca_
base-3.
int caNetConvert ( unsigned type, const void *pSrc, void *pDest,
# ifdef EPICS_CONVERSIO
if ( type >= NELEMENTS ( cac_dbr_cvrt ) ) {
return ECA_BADTYPE;
}
( * cac_dbr_cvrt [ type ] ) ( pSrc, pDest, hton, count );
# else
if ( INVALID_DB_REQ ( type ) ) {
return ECA_BADTYPE;
}
if ( pSrc != pDest ) {
memcpy ( pDest, pSrc, count );
}
# endif
return ECA_NORMAL;
}
The third argument in memcpy() must be not count but dbr_size_n( type, count ) - size in bytes, so instead of
memcpy( pDest, pSrc, count )
must be
memcpy( pDest, pSrc, dbr_size_n( type, count ) ).
Please check also cvrt_gr_char(), cvrt_ctrl_char(), cvrt_sts_char() and cvrt_time_char() routines from ca/convert.cpp where num (number of
values) is used in memcpy() calls.
Original Mantis Bug: mantis-288
http://
I committed this patch
cvs diff -r 1.11.2.4 -r 1.11.2.5 -u -wb -i -- convert.cpp convert.cpp ======= ======= ======= ======= ======= ======= ======= ======= ==== epicsmgr/ cvsroot/ epics/base/ src/ca/ convert. cpp,v
Index: convert.cpp
=======
RCS file: /net/phoebus/
retrieving revision 1.11.2.4
retrieving revision 1.11.2.5
diff -c -b -u -w -b -i -r1.11.2.4 -r1.11.2.5
cvs diff: conflicting specifications of output style
--- convert.cpp 18 Nov 2006 00:39:50 -0000 1.11.2.4
+++ convert.cpp 29 Mar 2007 16:31:38 -0000 1.11.2.5
@@ -1431,7 +1431,7 @@
return ECA_BADTYPE;
}
if ( pSrc != pDest ) {
- memcpy ( pDest, pSrc, count );
+ memcpy ( pDest, pSrc, dbr_size_n ( type, count ) );
}
# endif
return ECA_NORMAL;