patch-libmount_src_tab_parse_c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. --- util-linux-2.23.2.orig/libmount/src/tab_parse.c 2013-07-30 10:39:26.000000000 +0200
  2. +++ util-linux-2.23.2/libmount/src/tab_parse.c 2013-08-14 11:39:26.000000000 +0200
  3. @@ -16,6 +16,8 @@
  4. #include <dirent.h>
  5. #include <fcntl.h>
  6. +#define UL_SCNsA "%ms"
  7. +
  8. #include "at.h"
  9. #include "mangle.h"
  10. #include "mountP.h"
  11. @@ -59,18 +61,21 @@ static int next_number(char **s, int *nu
  12. static int mnt_parse_table_line(struct libmnt_fs *fs, char *s)
  13. {
  14. int rc, n = 0, xrc;
  15. - char *src = NULL, *fstype = NULL, *optstr = NULL;
  16. + int len = strlen (s) + 1;
  17. + char *fstype = malloc (sizeof *fstype * len);
  18. + char *optstr = malloc (sizeof *optstr * len);
  19. + char *src = malloc (sizeof *src * len);
  20. - rc = sscanf(s, UL_SCNsA" " /* (1) source */
  21. - UL_SCNsA" " /* (2) target */
  22. - UL_SCNsA" " /* (3) FS type */
  23. - UL_SCNsA" " /* (4) options */
  24. + rc = sscanf(s, "%s"" " /* (1) source */
  25. + "%s"" " /* (2) target */
  26. + "%s"" " /* (3) FS type */
  27. + "%s"" " /* (4) options */
  28. "%n", /* byte count */
  29. - &src,
  30. - &fs->target,
  31. - &fstype,
  32. - &optstr,
  33. + src,
  34. + fs->target,
  35. + fstype,
  36. + optstr,
  37. &n);
  38. xrc = rc;
  39. @@ -135,13 +140,18 @@ static int mnt_parse_mountinfo_line(stru
  40. int rc, end = 0;
  41. unsigned int maj, min;
  42. char *fstype = NULL, *src = NULL, *p;
  43. + int len = strlen (s) + 1;
  44. +
  45. + fs->root = malloc (sizeof *fs->root * len);
  46. + fs->target = malloc (sizeof *fs->target * len);
  47. + fs->vfs_optstr = malloc (sizeof *fs->vfs_optstr * len);
  48. rc = sscanf(s, "%u " /* (1) id */
  49. "%u " /* (2) parent */
  50. "%u:%u " /* (3) maj:min */
  51. - UL_SCNsA" " /* (4) mountroot */
  52. - UL_SCNsA" " /* (5) target */
  53. - UL_SCNsA /* (6) vfs options (fs-independent) */
  54. + "%s"" " /* (4) mountroot */
  55. + "%s"" " /* (5) target */
  56. + "%s" /* (6) vfs options (fs-independent) */
  57. "%n", /* number of read bytes */
  58. &fs->id,
  59. @@ -164,10 +174,14 @@ static int mnt_parse_mountinfo_line(stru
  60. if (p > s + 1)
  61. fs->opt_fields = strndup(s + 1, p - s - 1);
  62. s = p + 3;
  63. + len = strlen (s) + 1;
  64. + fstype = malloc (sizeof *fstype * len);
  65. + src = malloc (sizeof *src * len);
  66. + fs->fs_optstr = malloc (sizeof *fs->fs_optstr * len);
  67. - rc += sscanf(s, UL_SCNsA" " /* (8) FS type */
  68. - UL_SCNsA" " /* (9) source */
  69. - UL_SCNsA, /* (10) fs options (fs specific) */
  70. + rc += sscanf(s, "%s"" " /* (8) FS type */
  71. + "%s"" " /* (9) source */
  72. + "%s", /* (10) fs options (fs specific) */
  73. &fstype,
  74. &src,