From: Thorsten Kukuk <kukuk@suse.de>
To: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: Re: [PATCH] Avoid downloading whole NIS services.by{,service}name for getservby{name,port}{,_r} (, NULL)
Date: Fri, 02 Apr 2004 09:23:00 -0000 [thread overview]
Message-ID: <20040402092040.GA23511@suse.de> (raw)
In-Reply-To: <20040330073247.GA12333@suse.de>
[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]
On Tue, Mar 30, Thorsten Kukuk wrote:
> On Mon, Mar 29, Jakub Jelinek wrote:
>
> > Hi!
> >
> > Only lightly tested so far.
> > It is not neccessary to download, allocate and copy whole services
> > map and then search through it.
> > Instead, we can search already in the foreach callback and if we find
> > something tell the caller we don't need further input.
> >
> > BTW: __xdr_ypresp_all uses the foreach callback return value as
> > 0 -> need further data, != 0 break the loop.
> > But saveit callbacks I see return 0 when further data should be
> > examined and YP_FALSE (== 0) on error (e.g. memory failures).
> > This certainly doesn't sound right.
>
> There are two wrong checks:
>
> if (instatus != YP_TRUE)
> return instatus;
>
> and
>
> if (newp == NULL)
> return YP_FALSE; /* We have no error code for out of memory */
>
>
> are both wrong. I will look later at it and try to fix it.
> Seems I mixed the instatus and with the return value of the foreach
> function.
Attached is a patch to solve the problem. In error case, return
value should always be "1".
Thorsten
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de
SuSE Linux AG Maxfeldstr. 5 D-90409 Nuernberg
--------------------------------------------------------------------
Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B
[-- Attachment #2: glibc-2.3.3-nss_nis-return-code.diff --]
[-- Type: text/plain, Size: 3102 bytes --]
2004-04-02 Thorsten Kukuk <kukuk@firun.suse.de>
* nis/nss_nis/nis-ethers.c (saveit): Fix return codes in error case.
* nis/nss_nis/nis-initgroups.c (saveit): Likewise.
* nis/nss_nis/nis-proto.c (saveit): Likewise.
* nis/nss_nis/nis-rpc.c (saveit): Likewise.
* nis/nss_nis/nis-service.c (saveit): Likewise.
--- nis/nss_nis/nis-ethers.c
+++ nis/nss_nis/nis-ethers.c 2004/04/02 08:26:51
@@ -52,13 +52,13 @@
int invallen, char *indata)
{
if (instatus != YP_TRUE)
- return instatus;
+ return 1;
if (inkey && inkeylen > 0 && inval && invallen > 0)
{
struct response *newp = malloc (sizeof (struct response) + invallen + 1);
if (newp == NULL)
- return YP_FALSE; /* We have no error code for out of memory */
+ return 1; /* We have no error code for out of memory */
if (start == NULL)
start = newp;
--- nis/nss_nis/nis-initgroups.c
+++ nis/nss_nis/nis-initgroups.c 2004/04/02 08:33:11
@@ -59,14 +59,14 @@
intern_t *intern = (intern_t *) indata;
if (instatus != YP_TRUE)
- return instatus;
+ return 1;
if (inkey && inkeylen > 0 && inval && invallen > 0)
{
struct response_t *newp = malloc (sizeof (struct response_t)
+ invallen + 1);
if (newp == NULL)
- return YP_FALSE; /* We have no error code for out of memory */
+ return 1; /* We have no error code for out of memory */
if (intern->start == NULL)
intern->start = newp;
--- nis/nss_nis/nis-proto.c
+++ nis/nss_nis/nis-proto.c 2004/04/02 08:33:26
@@ -49,13 +49,13 @@
int invallen, char *indata)
{
if (instatus != YP_TRUE)
- return instatus;
+ return 1;
if (inkey && inkeylen > 0 && inval && invallen > 0)
{
struct response *newp = malloc (sizeof (struct response) + invallen + 1);
if (newp == NULL)
- return YP_FALSE; /* We have no error code for out of memory */
+ return 1; /* We have no error code for out of memory */
if (start == NULL)
start = newp;
--- nis/nss_nis/nis-rpc.c
+++ nis/nss_nis/nis-rpc.c 2004/04/02 08:33:40
@@ -57,14 +57,14 @@
intern_t *intern = (intern_t *)indata;
if (instatus != YP_TRUE)
- return instatus;
+ return 1;
if (inkey && inkeylen > 0 && inval && invallen > 0)
{
struct response_t *newp = malloc (sizeof (struct response_t)
+ invallen + 1);
if (newp == NULL)
- return YP_FALSE; /* We have no error code for out of memory */
+ return 1; /* We have no error code for out of memory */
if (intern->start == NULL)
intern->start = newp;
--- nis/nss_nis/nis-service.c
+++ nis/nss_nis/nis-service.c 2004/04/02 08:34:14
@@ -70,14 +70,14 @@
intern_t *intern = (intern_t *) indata;
if (instatus != YP_TRUE)
- return instatus;
+ return 1;
if (inkey && inkeylen > 0 && inval && invallen > 0)
{
struct response_t *newp = malloc (sizeof (struct response_t)
+ invallen + 1);
if (newp == NULL)
- return YP_FALSE; /* We have no error code for out of memory */
+ return 1; /* We have no error code for out of memory */
if (intern->start == NULL)
intern->start = newp;
next prev parent reply other threads:[~2004-04-02 9:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-30 7:32 Jakub Jelinek
2004-03-30 15:40 ` Ulrich Drepper
2004-03-30 21:30 ` Thorsten Kukuk
2004-04-02 9:23 ` Thorsten Kukuk [this message]
2004-04-02 15:10 ` Ulrich Drepper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040402092040.GA23511@suse.de \
--to=kukuk@suse.de \
--cc=libc-hacker@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).