When memcpy-ing, we need to be sure not to read beyond the end of the
source, or write beyond the end of the target.
Change-Id: I3cf259bedce4c6e88aef47ef5379aab198338cb7
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29404
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
tgt->f_frsize = htog(host->f_frsize, bo);
#endif
#if defined(__linux__)
- memcpy(&tgt->f_spare, &host->f_spare, sizeof(host->f_spare));
+ memcpy(&tgt->f_spare, &host->f_spare,
+ std::min(sizeof(host->f_spare), sizeof(tgt->f_spare)));
#else
/*
* The fields are different sizes per OS. Don't bother with