OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
2.0 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../musl/0008-fix-undefined-pointer-comparison-in-stdio-internal-_.patch
  5. # Copyright (C) 2016 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From 6d1a3dfeaf2caac4033a3c65822fb4e7e14866c7 Mon Sep 17 00:00:00 2001
  17. From: Rich Felker <dalias@aerifal.cx>
  18. Date: Mon, 28 Mar 2016 23:41:17 -0400
  19. Subject: [PATCH] fix undefined pointer comparison in stdio-internal __toread
  20. the comparison f->wpos > f->buf has undefined behavior when f->wpos is
  21. a null pointer, despite the intuition (and actual compiler behavior,
  22. for all known compilers) being that NULL > ptr is false for all valid
  23. pointers ptr.
  24. the purpose of the comparison is to determine if the write buffer is
  25. non-empty, and the idiom used elsewhere for that is comparison against
  26. f->wbase, which is either a null pointer when not writing, or equal to
  27. f->buf when writing. in the former case, both f->wpos and f->wbase are
  28. null; in the latter they are both non-null and point into the same
  29. array.
  30. ---
  31. src/stdio/__toread.c | 2 +-
  32. 1 file changed, 1 insertion(+), 1 deletion(-)
  33. diff --git a/src/stdio/__toread.c b/src/stdio/__toread.c
  34. index b08f5bb..35f67b8 100644
  35. --- a/src/stdio/__toread.c
  36. +++ b/src/stdio/__toread.c
  37. @@ -3,7 +3,7 @@
  38. int __toread(FILE *f)
  39. {
  40. f->mode |= f->mode-1;
  41. - if (f->wpos > f->buf) f->write(f, 0, 0);
  42. + if (f->wpos > f->wbase) f->write(f, 0, 0);
  43. f->wpos = f->wbase = f->wend = 0;
  44. if (f->flags & F_NORD) {
  45. f->flags |= F_ERR;
  46. --
  47. 2.7.4