001-no-printf-alloc.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. for systems that don't support latest POSIX standard: %as
  2. https://bugs.gentoo.org/406303
  3. --- a/configure.ac
  4. +++ b/configure.ac
  5. @@ -688,7 +688,6 @@ AC_ARG_ENABLE([libmount],
  6. UL_BUILD_INIT([libmount])
  7. UL_REQUIRES_LINUX([libmount])
  8. UL_REQUIRES_BUILD([libmount], [libblkid])
  9. -UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
  10. AM_CONDITIONAL(BUILD_LIBMOUNT, test "x$build_libmount" = xyes)
  11. AC_SUBST([LIBMOUNT_VERSION])
  12. --- a/libmount/src/tab_parse.c
  13. +++ b/libmount/src/tab_parse.c
  14. @@ -22,6 +22,10 @@
  15. #include "pathnames.h"
  16. #include "strutils.h"
  17. +#ifndef HAVE_SCANF_MS_MODIFIER
  18. +# define UL_SCNsA "%s"
  19. +#endif
  20. +
  21. static inline char *skip_spaces(char *s)
  22. {
  23. assert(s);
  24. @@ -61,16 +65,31 @@ static int mnt_parse_table_line(struct l
  25. int rc, n = 0, xrc;
  26. char *src = NULL, *fstype = NULL, *optstr = NULL;
  27. +#ifndef HAVE_SCANF_MS_MODIFIER
  28. + size_t len = strlen(s) + 1;
  29. + src = malloc(len);
  30. + fstype = malloc(len);
  31. + fs->target = malloc(len);
  32. + optstr = malloc(len);
  33. +#endif
  34. +
  35. rc = sscanf(s, UL_SCNsA" " /* (1) source */
  36. UL_SCNsA" " /* (2) target */
  37. UL_SCNsA" " /* (3) FS type */
  38. UL_SCNsA" " /* (4) options */
  39. "%n", /* byte count */
  40. +#ifdef HAVE_SCANF_MS_MODIFIER
  41. &src,
  42. &fs->target,
  43. &fstype,
  44. &optstr,
  45. +#else
  46. + src,
  47. + fs->target,
  48. + fstype,
  49. + optstr,
  50. +#endif
  51. &n);
  52. xrc = rc;
  53. @@ -136,6 +155,16 @@ static int mnt_parse_mountinfo_line(stru
  54. unsigned int maj, min;
  55. char *fstype = NULL, *src = NULL, *p;
  56. +#ifndef HAVE_SCANF_MS_MODIFIER
  57. + size_t len = strlen(s) + 1;
  58. + fs->root = malloc(len);
  59. + fs->target = malloc(len);
  60. + fs->vfs_optstr = malloc(len);
  61. + fs->fs_optstr = malloc(len);
  62. + fstype = malloc(len);
  63. + src = malloc(len);
  64. +#endif
  65. +
  66. rc = sscanf(s, "%u " /* (1) id */
  67. "%u " /* (2) parent */
  68. "%u:%u " /* (3) maj:min */
  69. @@ -147,9 +176,15 @@ static int mnt_parse_mountinfo_line(stru
  70. &fs->id,
  71. &fs->parent,
  72. &maj, &min,
  73. +#ifdef HAVE_SCANF_MS_MODIFIER
  74. &fs->root,
  75. &fs->target,
  76. &fs->vfs_optstr,
  77. +#else
  78. + fs->root,
  79. + fs->target,
  80. + fs->vfs_optstr,
  81. +#endif
  82. &end);
  83. if (rc >= 7 && end > 0)
  84. @@ -167,9 +202,15 @@ static int mnt_parse_mountinfo_line(stru
  85. UL_SCNsA" " /* (9) source */
  86. UL_SCNsA, /* (10) fs options (fs specific) */
  87. +#ifdef HAVE_SCANF_MS_MODIFIER
  88. &fstype,
  89. &src,
  90. &fs->fs_optstr);
  91. +#else
  92. + fstype,
  93. + src,
  94. + fs->fs_optstr);
  95. +#endif
  96. if (rc >= 10) {
  97. fs->flags |= MNT_FS_KERNEL;