logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0015-pwcache-Don-t-use-fixed-buffer-sizes.patch (2648B)


  1. From ab480e176692b91f2fb6fb9ea2e1725d980d805d Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Fri, 14 Apr 2017 11:25:01 -0700
  4. Subject: [PATCH] pwcache: Don't use fixed buffer sizes
  5. ---
  6. lib/libc/gen/pwcache.c | 20 ++++++++------------
  7. 1 file changed, 8 insertions(+), 12 deletions(-)
  8. diff --git a/lib/libc/gen/pwcache.c b/lib/libc/gen/pwcache.c
  9. index d54daa08cc7..2f30f4b966b 100644
  10. --- a/lib/libc/gen/pwcache.c
  11. +++ b/lib/libc/gen/pwcache.c
  12. @@ -202,8 +202,7 @@ grptb_start(void)
  13. const char *
  14. user_from_uid(uid_t uid, int noname)
  15. {
  16. - struct passwd pwstore, *pw = NULL;
  17. - char pwbuf[_PW_BUF_LEN];
  18. + struct passwd *pw;
  19. UIDC **pptr, *ptr = NULL;
  20. if ((uidtb != NULL) || (uidtb_start() == 0)) {
  21. @@ -226,7 +225,7 @@ user_from_uid(uid_t uid, int noname)
  22. *pptr = ptr = malloc(sizeof(UIDC));
  23. }
  24. - getpwuid_r(uid, &pwstore, pwbuf, sizeof(pwbuf), &pw);
  25. + pw = getpwuid(uid);
  26. if (pw == NULL) {
  27. /*
  28. * no match for this uid in the local password file
  29. @@ -263,8 +262,7 @@ user_from_uid(uid_t uid, int noname)
  30. const char *
  31. group_from_gid(gid_t gid, int noname)
  32. {
  33. - struct group grstore, *gr = NULL;
  34. - char grbuf[_GR_BUF_LEN];
  35. + struct group *gr;
  36. GIDC **pptr, *ptr = NULL;
  37. if ((gidtb != NULL) || (gidtb_start() == 0)) {
  38. @@ -287,7 +285,7 @@ group_from_gid(gid_t gid, int noname)
  39. *pptr = ptr = malloc(sizeof(GIDC));
  40. }
  41. - getgrgid_r(gid, &grstore, grbuf, sizeof(grbuf), &gr);
  42. + gr = getgrgid(gid);
  43. if (gr == NULL) {
  44. /*
  45. * no match for this gid in the local group file, put in
  46. @@ -322,8 +320,7 @@ group_from_gid(gid_t gid, int noname)
  47. int
  48. uid_from_user(const char *name, uid_t *uid)
  49. {
  50. - struct passwd pwstore, *pw = NULL;
  51. - char pwbuf[_PW_BUF_LEN];
  52. + struct passwd *pw;
  53. UIDC **pptr, *ptr = NULL;
  54. size_t namelen;
  55. @@ -357,7 +354,7 @@ uid_from_user(const char *name, uid_t *uid)
  56. * no match, look it up, if no match store it as an invalid entry,
  57. * or store the matching uid
  58. */
  59. - getpwnam_r(name, &pwstore, pwbuf, sizeof(pwbuf), &pw);
  60. + pw = getpwnam(name);
  61. if (ptr == NULL) {
  62. if (pw == NULL)
  63. return -1;
  64. @@ -383,8 +380,7 @@ uid_from_user(const char *name, uid_t *uid)
  65. int
  66. gid_from_group(const char *name, gid_t *gid)
  67. {
  68. - struct group grstore, *gr = NULL;
  69. - char grbuf[_GR_BUF_LEN];
  70. + struct group *gr;
  71. GIDC **pptr, *ptr = NULL;
  72. size_t namelen;
  73. @@ -418,7 +414,7 @@ gid_from_group(const char *name, gid_t *gid)
  74. * no match, look it up, if no match store it as an invalid entry,
  75. * or store the matching gid
  76. */
  77. - getgrnam_r(name, &grstore, grbuf, sizeof(grbuf), &gr);
  78. + gr = getgrnam(name);
  79. if (ptr == NULL) {
  80. if (gr == NULL)
  81. return -1;
  82. --
  83. 2.19.0