-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Milestone
Description
The build of 1.7.0 on armv7 FreeBSD 13.0-RELEASE still fails as reported in bug #629. The issue reported there was never actually fixed. This concerns this line of code:
/wrkdirs/usr/ports/devel/stlink/work/stlink-1.7.0/src/common.c:2222:16: error: implicit conversion loses integer precision: 'off_t' (aka 'long long') to 'size_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
mf->len = st.st_size;
~ ~~~^~~~~~~
1 error generated.
The problem is that while files are allowed to be very large, there is only a 32 bit address space on 32 bit machines. So size_t (for sizes of objects) is a 32 bit type while off_t (for sizes of files) is a 64 bit type. The correct resolution of this issue is to check if st.st_size is larger than SIZE_MAX (the largest possible size_t). If it is, an error must be returned immediately as the file is too large to be mapped. If st.st_size <= SIZE_MAX, a cast to size_t will not change the value and is thus correct to perform.
Please consider applying such a patch for 1.7.1.
Reactions are currently unavailable