001-no-printf-alloc.patch 2.3 KB

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