util-linux-001-sscanf-no-ms-as.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. Fix libmount build under uClibc
  2. See https://bugs.gentoo.org/show_bug.cgi?id=406303
  3. Patch from http://repository.timesys.com/buildsources/u/util-linux/util-linux-2.21.2/util-linux-2.21.2-sscanf-no-ms-as.patch ported to util-linux-2.22.2
  4. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
  5. diff -Nura util-linux-2.22.2/configure.ac util-linux-2.22.2-sscanf-no-ms-as/configure.ac
  6. --- util-linux-2.22.2/configure.ac 2012-12-13 08:16:02.973822890 -0300
  7. +++ util-linux-2.22.2-sscanf-no-ms-as/configure.ac 2013-03-07 14:50:39.975512873 -0300
  8. @@ -733,7 +733,6 @@
  9. UL_BUILD_INIT([libmount])
  10. UL_REQUIRES_LINUX([libmount])
  11. UL_REQUIRES_BUILD([libmount], [libblkid])
  12. -UL_REQUIRES_HAVE([libmount], [scanf_alloc_modifier], [scanf string alloc modifier])
  13. AM_CONDITIONAL(BUILD_LIBMOUNT, test "x$build_libmount" = xyes)
  14. AM_CONDITIONAL(BUILD_LIBMOUNT_TESTS, test "x$build_libmount" = xyes -a "x$enable_static" = xyes)
  15. diff -Nura util-linux-2.22.2/libmount/src/tab_parse.c util-linux-2.22.2-sscanf-no-ms-as/libmount/src/tab_parse.c
  16. --- util-linux-2.22.2/libmount/src/tab_parse.c 2012-12-12 17:04:47.906355128 -0300
  17. +++ util-linux-2.22.2-sscanf-no-ms-as/libmount/src/tab_parse.c 2013-03-07 15:08:29.589503961 -0300
  18. @@ -58,19 +58,21 @@
  19. */
  20. static int mnt_parse_table_line(struct libmnt_fs *fs, char *s)
  21. {
  22. - int rc, n = 0, xrc;
  23. - char *src = NULL, *fstype = NULL, *optstr = NULL;
  24. -
  25. - rc = sscanf(s, UL_SCNsA" " /* (1) source */
  26. - UL_SCNsA" " /* (2) target */
  27. - UL_SCNsA" " /* (3) FS type */
  28. - UL_SCNsA" " /* (4) options */
  29. + int rc, n = 0, len = strlen (s) + 1, xrc;
  30. + char *src = malloc (sizeof *src * len);
  31. + char *fstype = malloc (sizeof *fstype * len);
  32. + char *optstr = malloc (sizeof *optstr * len);
  33. +
  34. + rc = sscanf(s, "%s"" " /* (1) source */
  35. + "%s"" " /* (2) target */
  36. + "%s"" " /* (3) FS type */
  37. + "%s"" " /* (4) options */
  38. "%n", /* byte count */
  39. - &src,
  40. - &fs->target,
  41. - &fstype,
  42. - &optstr,
  43. + src,
  44. + fs->target,
  45. + fstype,
  46. + optstr,
  47. &n);
  48. xrc = rc;
  49. @@ -132,16 +134,20 @@
  50. */
  51. static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
  52. {
  53. - int rc, end = 0;
  54. + int rc, end = 0, len = strlen (s) + 1;
  55. unsigned int maj, min;
  56. char *fstype = NULL, *src = NULL, *p;
  57. + fs->root = malloc (sizeof *fs->root * len);
  58. + fs->target = malloc (sizeof *fs->target * len);
  59. + fs->vfs_optstr = malloc (sizeof *fs->vfs_optstr * len);
  60. +
  61. rc = sscanf(s, "%u " /* (1) id */
  62. "%u " /* (2) parent */
  63. "%u:%u " /* (3) maj:min */
  64. - UL_SCNsA" " /* (4) mountroot */
  65. - UL_SCNsA" " /* (5) target */
  66. - UL_SCNsA /* (6) vfs options (fs-independent) */
  67. + "%s"" " /* (4) mountroot */
  68. + "%s"" " /* (5) target */
  69. + "%s" /* (6) vfs options (fs-independent) */
  70. "%n", /* number of read bytes */
  71. &fs->id,
  72. @@ -163,9 +169,14 @@
  73. }
  74. s = p + 3;
  75. - rc += sscanf(s, UL_SCNsA" " /* (8) FS type */
  76. - UL_SCNsA" " /* (9) source */
  77. - UL_SCNsA, /* (10) fs options (fs specific) */
  78. + len = strlen (s) + 1;
  79. + fstype = malloc (sizeof *fstype * len);
  80. + src = malloc (sizeof *src * len);
  81. + fs->fs_optstr = malloc (sizeof *fs->fs_optstr * len);
  82. +
  83. + rc += sscanf(s, "%s"" " /* (8) FS type */
  84. + "%s"" " /* (9) source */
  85. + "%s", /* (10) fs options (fs specific) */
  86. &fstype,
  87. &src,
  88. @@ -274,11 +285,12 @@
  89. static int mnt_parse_swaps_line(struct libmnt_fs *fs, char *s)
  90. {
  91. uintmax_t fsz, usz;
  92. - int rc;
  93. - char *src = NULL;
  94. + int rc, len = strlen (s) + 1;
  95. + char *src = malloc (sizeof *src * len);
  96. + fs->swaptype = malloc (sizeof *fs->swaptype * len);
  97. - rc = sscanf(s, UL_SCNsA" " /* (1) source */
  98. - UL_SCNsA" " /* (2) type */
  99. + rc = sscanf(s, "%s" /* (1) source */
  100. + "%s" /* (2) type */
  101. "%jd" /* (3) size */
  102. "%jd" /* (4) used */
  103. "%d", /* priority */