diff options
author | V3n3RiX <venerix@koprulu.sector> | 2023-02-24 21:49:24 +0000 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2023-02-24 21:49:24 +0000 |
commit | a1c55a7e2f400a6170fd3df167bfdc299c05e2db (patch) | |
tree | 63add7e7943810930ca6e296397ef4bdea18eb6b /mail-mta/courier/files | |
parent | c18398e8c10c222f0daed55f7d69339e3c7885bd (diff) |
gentoo auto-resync : 24:02:2023 - 21:49:24
Diffstat (limited to 'mail-mta/courier/files')
-rw-r--r-- | mail-mta/courier/files/courier-1.2.2-fix-getgrnam-buffer.diff | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/mail-mta/courier/files/courier-1.2.2-fix-getgrnam-buffer.diff b/mail-mta/courier/files/courier-1.2.2-fix-getgrnam-buffer.diff new file mode 100644 index 000000000000..73384098189c --- /dev/null +++ b/mail-mta/courier/files/courier-1.2.2-fix-getgrnam-buffer.diff @@ -0,0 +1,120 @@ +diff -Naurp a/libs/numlib/changeuidgid.c b/libs/numlib/changeuidgid.c +--- a/libs/numlib/changeuidgid.c 2022-03-06 20:02:45.000000000 +0100 ++++ b/libs/numlib/changeuidgid.c 2023-02-24 17:26:02.452835861 +0100 +@@ -52,10 +52,11 @@ void libmail_changeuidgid(uid_t uid, gid + */ + uid_t libmail_getuid(const char *uname, gid_t *pw_gid) + { +- size_t bufsize; ++ int bufsize; + char *buf; + struct passwd pwbuf; + struct passwd *pw; ++ int s; + + /* + ** uname might be a pointer returned from a previous called to getpw(), +@@ -70,35 +71,39 @@ uid_t libmail_getuid(const char *uname, + } + strcpy(p, uname); + +-#ifdef _SC_GETGR_R_SIZE_MAX +- bufsize = sysconf(_SC_GETGR_R_SIZE_MAX); ++#ifdef _SC_GETPW_R_SIZE_MAX ++ bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); + if (bufsize == -1) /* Value was indeterminate */ +- { + #endif +- bufsize = 16384; /* Should be more than enough */ +- } +- +- buf = malloc(bufsize); +- if (buf == NULL) + { +- perror("malloc"); +- exit(1); ++ bufsize = 16384; /* Should be more than enough */ + } + ++ do { ++ buf = malloc(bufsize); ++ if (buf == NULL) ++ { ++ perror("malloc"); ++ exit(1); ++ } + +- errno=ENOENT; +- +- getpwnam_r(p, &pwbuf, buf, bufsize, &pw); ++ s = getpwnam_r(p, &pwbuf, buf, bufsize, &pw); ++ if (s == ERANGE) { ++ free(buf); ++ bufsize += 1024; ++ } ++ } while (s == ERANGE && bufsize <= 65536); + +- free(buf); ++ free(p); + + if (pw == 0) + { +- free(p); +- perror("getpwnam"); ++ errno = s; ++ perror("getpwnam_r"); + exit(1); + } +- free(p); ++ ++ free(buf); + + if ( pw_gid ) *pw_gid = pw->pw_gid; + +@@ -149,7 +154,7 @@ gid_t libmail_getgid(const char *gname) + struct group grp; + struct group *result; + char *buf; +- size_t bufsize; ++ int bufsize; + int s; + char *p=malloc(strlen(gname)+1); + +@@ -168,14 +173,21 @@ gid_t libmail_getgid(const char *gname) + bufsize = 16384; /* Should be more than enough */ + } + +- buf = malloc(bufsize); +- if (buf == NULL) +- { +- perror("malloc"); +- exit(1); +- } ++ do { ++ buf = malloc(bufsize); ++ if (buf == NULL) ++ { ++ perror("malloc"); ++ exit(1); ++ } ++ ++ s = getgrnam_r(p, &grp, buf, bufsize, &result); ++ if (s == ERANGE) { ++ free(buf); ++ bufsize += 1024; ++ } ++ } while (s == ERANGE && bufsize <= 65536); + +- s = getgrnam_r(p, &grp, buf, bufsize, &result); + free(p); + + if (result == NULL) +@@ -187,7 +199,7 @@ gid_t libmail_getgid(const char *gname) + else + { + errno = s; +- perror("getpwnam_r"); ++ perror("getgrnam_r"); + } + exit(1); + } |