summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2007-04-13 08:32:18 +0000
committerPeter Kjellerstedt <peter.kjellerstedt@axis.com>2007-04-13 08:32:18 +0000
commit07b15c5f21a951dfe8bbc0f2cd8ad98f75f7dda0 (patch)
tree405ca74df243f1b523c6ff11119abc032d5a5046 /libc
parent60dfbf13d6953f00b54bf6135aaad74de5b8e7b1 (diff)
Patch by Ricard Wanderlof <ricardw at axis dot com>:
* Add configurable buffer sizes for getpwnam() and getgrnam(). The default buffer size is, as before, 256 (glibc seems to use 1024 by default).
Diffstat (limited to 'libc')
-rw-r--r--libc/pwd_grp/pwd_grp.c44
-rw-r--r--libc/unistd/sysconf.c6
2 files changed, 20 insertions, 30 deletions
diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c
index d223a9e36..18aeacc42 100644
--- a/libc/pwd_grp/pwd_grp.c
+++ b/libc/pwd_grp/pwd_grp.c
@@ -55,14 +55,6 @@ libc_hidden_proto(__ctype_b)
#endif
/**********************************************************************/
-/* Sizes for statically allocated buffers. */
-
-/* If you change these values, also change _SC_GETPW_R_SIZE_MAX and
- * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */
-#define PWD_BUFFER_SIZE 256
-#define GRP_BUFFER_SIZE 256
-
-/**********************************************************************/
/* Prototypes for internal functions. */
extern int __parsepwent(void *pw, char *line) attribute_hidden;
@@ -165,7 +157,7 @@ libc_hidden_proto(fgetpwent_r)
struct passwd *fgetpwent(FILE *stream)
{
- static char buffer[PWD_BUFFER_SIZE];
+ static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
static struct passwd resultbuf;
struct passwd *result;
@@ -183,7 +175,7 @@ libc_hidden_proto(fgetgrent_r)
struct group *fgetgrent(FILE *stream)
{
- static char buffer[GRP_BUFFER_SIZE];
+ static char buffer[__UCLIBC_GRP_BUFFER_SIZE__];
static struct group resultbuf;
struct group *result;
@@ -200,7 +192,7 @@ libc_hidden_proto(fgetspent_r)
struct spwd *fgetspent(FILE *stream)
{
- static char buffer[PWD_BUFFER_SIZE];
+ static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
static struct spwd resultbuf;
struct spwd *result;
@@ -220,7 +212,7 @@ int sgetspent_r(const char *string, struct spwd *result_buf,
*result = NULL;
- if (buflen < PWD_BUFFER_SIZE) {
+ if (buflen < __UCLIBC_PWD_BUFFER_SIZE__) {
DO_ERANGE:
__set_errno(rv);
goto DONE;
@@ -306,7 +298,7 @@ libc_hidden_proto(getpwuid_r)
struct passwd *getpwuid(uid_t uid)
{
- static char buffer[PWD_BUFFER_SIZE];
+ static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
static struct passwd resultbuf;
struct passwd *result;
@@ -322,7 +314,7 @@ libc_hidden_proto(getgrgid_r)
struct group *getgrgid(gid_t gid)
{
- static char buffer[GRP_BUFFER_SIZE];
+ static char buffer[__UCLIBC_GRP_BUFFER_SIZE__];
static struct group resultbuf;
struct group *result;
@@ -348,7 +340,7 @@ int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf,
int rv;
struct passwd *pp;
struct passwd password;
- char pwd_buff[PWD_BUFFER_SIZE];
+ char pwd_buff[__UCLIBC_PWD_BUFFER_SIZE__];
*result = NULL;
if (!(rv = getpwuid_r(uid, &password, pwd_buff, sizeof(pwd_buff), &pp))) {
@@ -369,7 +361,7 @@ libc_hidden_proto(getspuid_r)
struct spwd *getspuid(uid_t uid)
{
- static char buffer[PWD_BUFFER_SIZE];
+ static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
static struct spwd resultbuf;
struct spwd *result;
@@ -385,7 +377,7 @@ libc_hidden_proto(getpwnam_r)
struct passwd *getpwnam(const char *name)
{
- static char buffer[PWD_BUFFER_SIZE];
+ static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
static struct passwd resultbuf;
struct passwd *result;
@@ -401,7 +393,7 @@ libc_hidden_proto(getgrnam_r)
struct group *getgrnam(const char *name)
{
- static char buffer[GRP_BUFFER_SIZE];
+ static char buffer[__UCLIBC_GRP_BUFFER_SIZE__];
static struct group resultbuf;
struct group *result;
@@ -417,7 +409,7 @@ libc_hidden_proto(getspnam_r)
struct spwd *getspnam(const char *name)
{
- static char buffer[PWD_BUFFER_SIZE];
+ static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
static struct spwd resultbuf;
struct spwd *result;
@@ -435,7 +427,7 @@ int getpw(uid_t uid, char *buf)
{
struct passwd resultbuf;
struct passwd *result;
- char buffer[PWD_BUFFER_SIZE];
+ char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
if (!buf) {
__set_errno(EINVAL);
@@ -634,7 +626,7 @@ libc_hidden_proto(getpwent_r)
struct passwd *getpwent(void)
{
- static char line_buff[PWD_BUFFER_SIZE];
+ static char line_buff[__UCLIBC_PWD_BUFFER_SIZE__];
static struct passwd pwd;
struct passwd *result;
@@ -650,7 +642,7 @@ libc_hidden_proto(getgrent_r)
struct group *getgrent(void)
{
- static char line_buff[GRP_BUFFER_SIZE];
+ static char line_buff[__UCLIBC_GRP_BUFFER_SIZE__];
static struct group gr;
struct group *result;
@@ -666,7 +658,7 @@ libc_hidden_proto(getspent_r)
struct spwd *getspent(void)
{
- static char line_buff[PWD_BUFFER_SIZE];
+ static char line_buff[__UCLIBC_PWD_BUFFER_SIZE__];
static struct spwd spwd;
struct spwd *result;
@@ -682,7 +674,7 @@ libc_hidden_proto(sgetspent_r)
struct spwd *sgetspent(const char *string)
{
- static char line_buff[PWD_BUFFER_SIZE];
+ static char line_buff[__UCLIBC_PWD_BUFFER_SIZE__];
static struct spwd spwd;
struct spwd *result;
@@ -705,7 +697,7 @@ int initgroups(const char *user, gid_t gid)
int num_groups, rv;
char **m;
struct group group;
- char buff[PWD_BUFFER_SIZE];
+ char buff[__UCLIBC_PWD_BUFFER_SIZE__];
rv = -1;
@@ -1134,7 +1126,7 @@ int attribute_hidden __pgsreader(int (*__parserfunc)(void *d, char *line), void
int rv = ERANGE;
__STDIO_AUTO_THREADLOCK_VAR;
- if (buflen < PWD_BUFFER_SIZE) {
+ if (buflen < __UCLIBC_PWD_BUFFER_SIZE__) {
__set_errno(rv);
} else {
__STDIO_AUTO_THREADLOCK(f);
diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c
index 66bcf9045..9f2ca8d0b 100644
--- a/libc/unistd/sysconf.c
+++ b/libc/unistd/sysconf.c
@@ -568,13 +568,11 @@ long int sysconf(int name)
#endif
/* If you change these, also change libc/pwd_grp/pwd_grp.c to match */
-#define PWD_BUFFER_SIZE 256
-#define GRP_BUFFER_SIZE 256
case _SC_GETGR_R_SIZE_MAX:
- return GRP_BUFFER_SIZE;
+ return __UCLIBC_GRP_BUFFER_SIZE__;
case _SC_GETPW_R_SIZE_MAX:
- return PWD_BUFFER_SIZE;
+ return __UCLIBC_PWD_BUFFER_SIZE__;
/* getlogin() is a worthless interface. In uClibc we let the user specify
* whatever they want via the LOGNAME environment variable, or we return NULL