diff options
Diffstat (limited to 'nss/nss_db')
-rw-r--r-- | nss/nss_db/db-XXX.c | 22 | ||||
-rw-r--r-- | nss/nss_db/db-alias.c | 13 | ||||
-rw-r--r-- | nss/nss_db/db-netgrp.c | 8 |
3 files changed, 25 insertions, 18 deletions
diff --git a/nss/nss_db/db-XXX.c b/nss/nss_db/db-XXX.c index 2f781bf3d9..4d20cae797 100644 --- a/nss/nss_db/db-XXX.c +++ b/nss/nss_db/db-XXX.c @@ -147,9 +147,10 @@ CONCAT(_nss_db_end,ENTNAME) (void) /* Do a database lookup for KEY. */ static enum nss_status lookup (const DBT *key, struct STRUCTURE *result, - void *buffer, int buflen H_ERRNO_PROTO) + void *buffer, size_t buflen, int *errnop H_ERRNO_PROTO) { enum nss_status status; + int err; DBT value; /* Open the database. */ @@ -158,9 +159,12 @@ lookup (const DBT *key, struct STRUCTURE *result, return status; /* Succeed iff it matches a value that parses correctly. */ - status = (((*db->get) (db, key, &value, 0) == 0 && - parse_line (value.data, result, buffer, buflen)) - ? NSS_STATUS_SUCCESS : NSS_STATUS_NOTFOUND); + err = ((*db->get) (db, key, &value, 0) == 0 && + parse_line (value.data, result, buffer, buflen, errnop)); + if (err == 0) + status = NSS_STATUS_SUCCESS; + else + status = err < 0 ? NSS_STATUS_TRYAGAIN : NSS_STATUS_NOTFOUND; if (! keep_db) internal_endent (); @@ -188,7 +192,7 @@ lookup (const DBT *key, struct STRUCTURE *result, enum nss_status \ _nss_db_get##name##_r (proto, \ struct STRUCTURE *result, \ - char *buffer, size_t buflen H_ERRNO_PROTO) \ + char *buffer, size_t buflen, int *errnop H_ERRNO_PROTO)\ { \ DBT key; \ enum nss_status status; \ @@ -196,7 +200,7 @@ _nss_db_get##name##_r (proto, \ key.data = __alloca (size); \ key.size = KEYPRINTF keypattern; \ __libc_lock_lock (lock); \ - status = lookup (&key, result, buffer, buflen H_ERRNO_ARG); \ + status = lookup (&key, result, buffer, buflen, errnop H_ERRNO_ARG); \ __libc_lock_unlock (lock); \ return status; \ } @@ -208,8 +212,8 @@ _nss_db_get##name##_r (proto, \ /* Return the next entry from the database file, doing locking. */ enum nss_status -CONCAT(_nss_db_get,ENTNAME_r) (struct STRUCTURE *result, - char *buffer, size_t buflen H_ERRNO_PROTO) +CONCAT(_nss_db_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer, + size_t buflen, int *errnop H_ERRNO_PROTO) { /* Return next entry in host file. */ enum nss_status status; @@ -218,7 +222,7 @@ CONCAT(_nss_db_get,ENTNAME_r) (struct STRUCTURE *result, __libc_lock_lock (lock); key.size = 1 + snprintf (key.data = buf, sizeof buf, "0%u", entidx++); - status = lookup (&key, result, buffer, buflen H_ERRNO_ARG); + status = lookup (&key, result, buffer, buflen, errnop H_ERRNO_ARG); __libc_lock_unlock (lock); return status; diff --git a/nss/nss_db/db-alias.c b/nss/nss_db/db-alias.c index 32ba4b5f4f..0e72b92ceb 100644 --- a/nss/nss_db/db-alias.c +++ b/nss/nss_db/db-alias.c @@ -134,7 +134,7 @@ _nss_db_endaliasent (void) the result. */ static enum nss_status lookup (const DBT *key, struct aliasent *result, char *buffer, - size_t buflen) + size_t buflen, int *errnop) { enum nss_status status; DBT value; @@ -154,7 +154,7 @@ lookup (const DBT *key, struct aliasent *result, char *buffer, if (buflen < key->size + 1) { no_more_room: - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -218,7 +218,8 @@ lookup (const DBT *key, struct aliasent *result, char *buffer, } enum nss_status -_nss_db_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen) +_nss_db_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen, + int *errnop) { /* Return next entry in host file. */ enum nss_status status; @@ -227,7 +228,7 @@ _nss_db_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen) __libc_lock_lock (lock); key.size = 1 + snprintf (key.data = buf, sizeof buf, "0%u", entidx++); - status = lookup (&key, result, buffer, buflen); + status = lookup (&key, result, buffer, buflen, errnop); __libc_lock_unlock (lock); return status; @@ -236,7 +237,7 @@ _nss_db_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen) enum nss_status _nss_db_getaliasbyname_r (const char *name, struct aliasent *result, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { DBT key; enum nss_status status; @@ -248,7 +249,7 @@ _nss_db_getaliasbyname_r (const char *name, struct aliasent *result, memcpy (&((char *) key.data)[1], name, key.size - 1); __libc_lock_lock (lock); - status = lookup (&key, result, buffer, buflen); + status = lookup (&key, result, buffer, buflen, errnop); __libc_lock_unlock (lock); return status; diff --git a/nss/nss_db/db-netgrp.c b/nss/nss_db/db-netgrp.c index 4691c0fb9b..d63d1cb1af 100644 --- a/nss/nss_db/db-netgrp.c +++ b/nss/nss_db/db-netgrp.c @@ -112,16 +112,18 @@ _nss_db_endnetgrent (void) extern enum nss_status _nss_netgroup_parseline (char **cursor, struct __netgrent *result, - char *buffer, int buflen); + char *buffer, size_t buflen, + int *errnop); enum nss_status -_nss_db_getnetgrent_r (struct __netgrent *result, char *buffer, int buflen) +_nss_db_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen, + int *errnop) { int status; __libc_lock_lock (lock); - status = _nss_netgroup_parseline (&cursor, result, buffer, buflen); + status = _nss_netgroup_parseline (&cursor, result, buffer, buflen, errnop); __libc_lock_unlock (lock); |