• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisión50bd6d06e3f2cca57bd20cf4345993ceff8c97dd (tree)
Tiempo2020-09-15 22:26:34
AutorYann Sionneau <ysionneau@kalr...>
CommiterWaldemar Brodkorb

Log Message

Fix memory corruption due to struct stat field

Kernel stat/stat64 structure and uClibc-ng ones were not
in sync regarding the timespec fields.
Kernel had them but uClibc did not expose it in some cases.

Man page says that stat struct should have timespec fields if:
* _POSIX_C_SOURCE is defined to 200809L or greater
or
* _XOPEN_SOURCE is defined to 700 or greater
or
* _BSD_SOURCE is defined
or
* _SVID_SOURCE is defined

In the case of buildroot vim build, neither _BSD_SOURCE nor _SVID_SOURCE were defined.
Only _POSIX_C_SOURCE and _XOPEN_SOURCE were defined.

uClibc-ng header only checked for _BSD_SOURCE and _SVID_SOURCE via USE_MISC.

This patch adds a check to USE_XOPEN2K8 which is defined
if _POSIX_C_SOURCE >= 200809L or _XOPEN_SOURCE >= 700

This for instance fixes a crash at startup of vim (not the busybox one) on aarch64 and all other
arch where in kernel STAT_HAVE_NSEC is set and where stat.h in uClibc-ng comes from libc/sysdeps/linux/common-generic/bits

Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>

Cambiar Resumen

Diferencia incremental

--- a/libc/sysdeps/linux/common-generic/bits/stat.h
+++ b/libc/sysdeps/linux/common-generic/bits/stat.h
@@ -47,7 +47,7 @@ struct stat
4747 int st_blksize; /* Optimal block size for I/O. */
4848 int __pad2;
4949 long long st_blocks; /* Number 512-byte blocks allocated */
50-#ifdef __USE_MISC
50+#if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
5151 /* Nanosecond resolution timestamps are stored in a format
5252 equivalent to 'struct timespec'. This is the type used
5353 whenever possible but the Unix namespace rules do not allow the
@@ -88,7 +88,7 @@ struct stat64
8888 int st_blksize; /* Optimal block size for I/O. */
8989 int __pad4;
9090 long long st_blocks; /* Number 512-byte blocks allocated */
91-# ifdef __USE_MISC
91+# if defined(__USE_MISC) || defined(__USE_XOPEN2K8)
9292 /* Nanosecond resolution timestamps are stored in a format
9393 equivalent to 'struct timespec'. This is the type used
9494 whenever possible but the Unix namespace rules do not allow the