From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23508 invoked by alias); 24 Mar 2006 21:39:34 -0000 Received: (qmail 23492 invoked by uid 22791); 24 Mar 2006 21:39:34 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 24 Mar 2006 21:39:30 +0000 Received: from sunsite.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id k2OLcweQ028422; Fri, 24 Mar 2006 22:38:58 +0100 Received: (from jj@localhost) by sunsite.mff.cuni.cz (8.13.1/8.13.1/Submit) id k2OLcv7u028411; Fri, 24 Mar 2006 22:38:57 +0100 Date: Fri, 24 Mar 2006 21:39:00 -0000 From: Jakub Jelinek To: Ulrich Drepper , Roland McGrath Cc: Glibc hackers Subject: [PATCH] Fix NIS+ Message-ID: <20060324213856.GA30252@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2006-03/txt/msg00038.txt.bz2 Hi! We really should be checking the return value of malloc, otherwise all _nss_*create_tablename functions always fail and set *errnop to some random errno value inherited from the application. They first check if (tablename_val == NULL) { prepare...; char *p = malloc (...); if (tablename_val == NULL) { *errnop = errno; return NSS_STATUS_TRYAGAIN; } } and prepare... doesn't touch tablename_val, so it always fails. 2006-03-24 Jakub Jelinek * nis/nss_nisplus/nisplus-proto.c (_nss_create_tablename): Check the return value of malloc rather than the static var again. * nis/nss_nisplus/nisplus-grp.c (_nss_create_tablename): Likewise. * nis/nss_nisplus/nisplus-network.c (_nss_create_tablename): Likewise. * nis/nss_nisplus/nisplus-ethers.c (_nss_create_tablename): Likewise. * nis/nss_nisplus/nisplus-rpc.c (_nss_create_tablename): Likewise. * nis/nss_nisplus/nisplus-service.c (_nss_create_tablename): Likewise. * nis/nss_nisplus/nisplus-hosts.c (_nss_create_tablename): Likewise. * nis/nss_nisplus/nisplus-alias.c (_nss_create_tablename): Likewise. * nis/nss_nisplus/nisplus-pwd.c (_nss_pwd_create_tablename): Likewise. --- libc/nis/nss_nisplus/nisplus-proto.c.jj 2005-12-06 11:22:03.000000000 +0100 +++ libc/nis/nss_nisplus/nisplus-proto.c 2006-03-24 22:16:00.000000000 +0100 @@ -1,4 +1,5 @@ -/* Copyright (C) 1997,1998,2001,2002,2003,2005 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 2001, 2002, 2003, 2005, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -147,7 +148,7 @@ _nss_create_tablename (int *errnop) static const char prefix[] = "protocols.org_dir."; char *p = malloc (sizeof (prefix) + local_dir_len); - if (tablename_val == NULL) + if (p == NULL) { *errnop = errno; return NSS_STATUS_TRYAGAIN; --- libc/nis/nss_nisplus/nisplus-grp.c.jj 2005-12-06 11:22:02.000000000 +0100 +++ libc/nis/nss_nisplus/nisplus-grp.c 2006-03-24 22:13:33.000000000 +0100 @@ -1,4 +1,5 @@ -/* Copyright (C) 1997, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +/* Copyright (C) 1997, 2001, 2002, 2003, 2005, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -47,7 +48,7 @@ _nss_create_tablename (int *errnop) static const char prefix[] = "group.org_dir."; char *p = malloc (sizeof (prefix) + local_dir_len); - if (tablename_val == NULL) + if (p == NULL) { *errnop = errno; return NSS_STATUS_TRYAGAIN; --- libc/nis/nss_nisplus/nisplus-network.c.jj 2005-12-06 11:22:03.000000000 +0100 +++ libc/nis/nss_nisplus/nisplus-network.c 2006-03-24 22:15:05.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 1997,1998,2000-2003,2005 Free Software Foundation, Inc. +/* Copyright (C) 1997,1998,2000-2003,2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -148,7 +148,7 @@ _nss_create_tablename (int *errnop) static const char prefix[] = "networks.org_dir."; char *p = malloc (sizeof (prefix) + local_dir_len); - if (tablename_val == NULL) + if (p == NULL) { *errnop = errno; return NSS_STATUS_TRYAGAIN; --- libc/nis/nss_nisplus/nisplus-pwd.c.jj 2005-12-06 11:22:03.000000000 +0100 +++ libc/nis/nss_nisplus/nisplus-pwd.c 2006-03-24 22:17:43.000000000 +0100 @@ -1,4 +1,5 @@ -/* Copyright (C) 1997,1999,2001,2002,2003,2005 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1999, 2001, 2002, 2003, 2005, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -44,7 +45,7 @@ _nss_pwd_create_tablename (int *errnop) static const char prefix[] = "passwd.org_dir."; char *p = malloc (sizeof (prefix) + local_dir_len); - if (pwd_tablename_val == NULL) + if (p == NULL) { *errnop = errno; return NSS_STATUS_TRYAGAIN; --- libc/nis/nss_nisplus/nisplus-ethers.c.jj 2005-12-06 11:22:02.000000000 +0100 +++ libc/nis/nss_nisplus/nisplus-ethers.c 2006-03-24 22:12:44.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 1997,1998,2000-2003,2005 Free Software Foundation, Inc. +/* Copyright (C) 1997,1998,2000-2003,2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -94,7 +94,7 @@ _nss_create_tablename (int *errnop) static const char prefix[] = "ethers.org_dir."; char *p = malloc (sizeof (prefix) + local_dir_len); - if (tablename_val == NULL) + if (p == NULL) { *errnop = errno; return NSS_STATUS_TRYAGAIN; --- libc/nis/nss_nisplus/nisplus-rpc.c.jj 2005-12-06 11:22:03.000000000 +0100 +++ libc/nis/nss_nisplus/nisplus-rpc.c 2006-03-24 22:18:24.000000000 +0100 @@ -1,4 +1,5 @@ -/* Copyright (C) 1997,1998,2001,2002,2003,2005 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 2001, 2002, 2003, 2005, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -144,7 +145,7 @@ _nss_create_tablename (int *errnop) static const char prefix[] = "rpc.org_dir."; char *p = malloc (sizeof (prefix) + local_dir_len); - if (tablename_val == NULL) + if (p == NULL) { *errnop = errno; return NSS_STATUS_TRYAGAIN; --- libc/nis/nss_nisplus/nisplus-service.c.jj 2005-12-06 11:22:03.000000000 +0100 +++ libc/nis/nss_nisplus/nisplus-service.c 2006-03-24 22:19:02.000000000 +0100 @@ -1,4 +1,5 @@ -/* Copyright (C) 1997-1999,2001,2002,2003,2005 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003, 2005, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -151,7 +152,7 @@ _nss_create_tablename (int *errnop) static const char prefix[] = "services.org_dir."; char *p = malloc (sizeof (prefix) + local_dir_len); - if (tablename_val == NULL) + if (p == NULL) { *errnop = errno; return NSS_STATUS_TRYAGAIN; --- libc/nis/nss_nisplus/nisplus-hosts.c.jj 2005-12-06 11:22:02.000000000 +0100 +++ libc/nis/nss_nisplus/nisplus-hosts.c 2006-03-24 22:14:03.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2002, 2003, 2005 Free Software Foundation, Inc. +/* Copyright (C) 1997-2002, 2003, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -186,7 +186,7 @@ _nss_create_tablename (int *errnop) static const char prefix[] = "hosts.org_dir."; char *p = malloc (sizeof (prefix) + local_dir_len); - if (tablename_val == NULL) + if (p == NULL) { *errnop = errno; return NSS_STATUS_TRYAGAIN; --- libc/nis/nss_nisplus/nisplus-alias.c.jj 2005-12-06 11:22:02.000000000 +0100 +++ libc/nis/nss_nisplus/nisplus-alias.c 2006-03-24 22:12:16.000000000 +0100 @@ -1,4 +1,5 @@ -/* Copyright (C) 1997,1998,2001,2002,2003,2005 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 2001, 2002, 2003, 2005, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -51,7 +52,7 @@ _nss_create_tablename (int *errnop) static const char prefix[] = "mail_aliases.org_dir."; char *p = malloc (sizeof (prefix) + local_dir_len); - if (tablename_val == NULL) + if (p == NULL) { *errnop = errno; return NSS_STATUS_TRYAGAIN; Jakub