0001-Fixed-reporting-an-error-when-failed-to-build-the-mo.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. From 85c1634a26faa572d3c558d4cf8aaaca5202d4e9 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= <jean-pierre.andre@wanadoo.fr>
  3. Date: Wed, 19 Dec 2018 15:57:50 +0100
  4. Subject: [PATCH] Fixed reporting an error when failed to build the mountpoint
  5. The size check was inefficient because getcwd() uses an unsigned int
  6. argument.
  7. Fixes CVE-2019-9755: An integer underflow issue exists in ntfs-3g 2017.3.23.
  8. A local attacker could potentially exploit this by running /bin/ntfs-3g with
  9. specially crafted arguments from a specially crafted directory to cause a
  10. heap buffer overflow, resulting in a crash or the ability to execute
  11. arbitrary code. In installations where /bin/ntfs-3g is a setuid-root
  12. binary, this could lead to a local escalation of privileges.
  13. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  14. ---
  15. src/lowntfs-3g.c | 6 +++++-
  16. src/ntfs-3g.c | 6 +++++-
  17. 2 files changed, 10 insertions(+), 2 deletions(-)
  18. diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c
  19. index 993867fa..0660439b 100644
  20. --- a/src/lowntfs-3g.c
  21. +++ b/src/lowntfs-3g.c
  22. @@ -4411,7 +4411,8 @@ int main(int argc, char *argv[])
  23. else {
  24. ctx->abs_mnt_point = (char*)ntfs_malloc(PATH_MAX);
  25. if (ctx->abs_mnt_point) {
  26. - if (getcwd(ctx->abs_mnt_point,
  27. + if ((strlen(opts.mnt_point) < PATH_MAX)
  28. + && getcwd(ctx->abs_mnt_point,
  29. PATH_MAX - strlen(opts.mnt_point) - 1)) {
  30. strcat(ctx->abs_mnt_point, "/");
  31. strcat(ctx->abs_mnt_point, opts.mnt_point);
  32. @@ -4419,6 +4420,9 @@ int main(int argc, char *argv[])
  33. /* Solaris also wants the absolute mount point */
  34. opts.mnt_point = ctx->abs_mnt_point;
  35. #endif /* defined(__sun) && defined (__SVR4) */
  36. + } else {
  37. + free(ctx->abs_mnt_point);
  38. + ctx->abs_mnt_point = (char*)NULL;
  39. }
  40. }
  41. }
  42. diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c
  43. index 6ce89fef..4e0912ae 100644
  44. --- a/src/ntfs-3g.c
  45. +++ b/src/ntfs-3g.c
  46. @@ -4148,7 +4148,8 @@ int main(int argc, char *argv[])
  47. else {
  48. ctx->abs_mnt_point = (char*)ntfs_malloc(PATH_MAX);
  49. if (ctx->abs_mnt_point) {
  50. - if (getcwd(ctx->abs_mnt_point,
  51. + if ((strlen(opts.mnt_point) < PATH_MAX)
  52. + && getcwd(ctx->abs_mnt_point,
  53. PATH_MAX - strlen(opts.mnt_point) - 1)) {
  54. strcat(ctx->abs_mnt_point, "/");
  55. strcat(ctx->abs_mnt_point, opts.mnt_point);
  56. @@ -4156,6 +4157,9 @@ int main(int argc, char *argv[])
  57. /* Solaris also wants the absolute mount point */
  58. opts.mnt_point = ctx->abs_mnt_point;
  59. #endif /* defined(__sun) && defined (__SVR4) */
  60. + } else {
  61. + free(ctx->abs_mnt_point);
  62. + ctx->abs_mnt_point = (char*)NULL;
  63. }
  64. }
  65. }
  66. --
  67. 2.20.1