aboutsummaryrefslogtreecommitdiff
path: root/nis
diff options
context:
space:
mode:
Diffstat (limited to 'nis')
-rw-r--r--nis/nis_print.c10
-rw-r--r--nis/nss_nisplus/nisplus-parser.c78
-rw-r--r--nis/nss_nisplus/nisplus-pwd.c6
3 files changed, 62 insertions, 32 deletions
diff --git a/nis/nis_print.c b/nis/nis_print.c
index 4ad51b2..ded5f5a 100644
--- a/nis/nis_print.c
+++ b/nis/nis_print.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -311,6 +311,8 @@ nis_print_entry (const entry_obj *obj)
void
nis_print_object (const nis_object * obj)
{
+ time_t buf;
+
printf (_("Object Name : %s\n"), obj->zo_name);
printf (_("Directory : %s\n"), obj->zo_domain);
printf (_("Owner : %s\n"), obj->zo_owner);
@@ -319,8 +321,10 @@ nis_print_object (const nis_object * obj)
nis_print_rights (obj->zo_access);
printf (_("\nTime to Live : "));
print_ttl (obj->zo_ttl);
- printf (_("Creation Time : %s"), ctime ((time_t *)&obj->zo_oid.ctime));
- printf (_("Mod. Time : %s"), ctime ((time_t *)&obj->zo_oid.mtime));
+ buf = obj->zo_oid.ctime;
+ printf (_("Creation Time : %s"), ctime (&buf));
+ buf = obj->zo_oid.mtime;
+ printf (_("Mod. Time : %s"), ctime (&buf));
fputs (_("Object Type : "), stdout);
nis_print_objtype (obj->zo_data.zo_type);
switch (obj->zo_data.zo_type)
diff --git a/nis/nss_nisplus/nisplus-parser.c b/nis/nss_nisplus/nisplus-parser.c
index fa4073e..35b8a28 100644
--- a/nis/nss_nisplus/nisplus-parser.c
+++ b/nis/nss_nisplus/nisplus-parser.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -38,6 +38,7 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
{
char *first_unused = buffer;
size_t room_left = buflen;
+ size_t len;
if (result == NULL)
return 0;
@@ -61,9 +62,12 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
strncpy (first_unused, NISENTRYVAL (0, 0, result),
NISENTRYLEN (0, 0, result));
first_unused[NISENTRYLEN (0, 0, result)] = '\0';
+ len = strlen (first_unused);
+ if (len == 0) /* No name ? Should never happen, database is corrupt */
+ return 0;
pw->pw_name = first_unused;
- room_left -= (strlen (first_unused) +1);
- first_unused += strlen (first_unused) +1;
+ room_left -= (len + 1);
+ first_unused += (len + 1);
if (NISENTRYLEN (0, 1, result) >= room_left)
goto no_more_room;
@@ -72,8 +76,9 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
NISENTRYLEN (0, 1, result));
first_unused[NISENTRYLEN (0, 1, result)] = '\0';
pw->pw_passwd = first_unused;
- room_left -= (strlen (first_unused) +1);
- first_unused += strlen (first_unused) +1;
+ len = strlen (first_unused);
+ room_left -= (len + 1);
+ first_unused += (len + 1);
if (NISENTRYLEN(0, 2, result) >= room_left)
goto no_more_room;
@@ -81,9 +86,12 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
strncpy (first_unused, NISENTRYVAL (0, 2, result),
NISENTRYLEN (0, 2, result));
first_unused[NISENTRYLEN (0, 2, result)] = '\0';
+ len = strlen (first_unused);
+ if (len == 0) /* If we don't have a uid, it's an invalid shadow entry */
+ return 0;
pw->pw_uid = atoi (first_unused);
- room_left -= (strlen (first_unused) +1);
- first_unused += strlen (first_unused) +1;
+ room_left -= (len + 1);
+ first_unused += (len + 1);
if (NISENTRYLEN (0, 3, result) >= room_left)
goto no_more_room;
@@ -91,9 +99,12 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
strncpy (first_unused, NISENTRYVAL (0, 3, result),
NISENTRYLEN (0, 3, result));
first_unused[NISENTRYLEN (0, 3, result)] = '\0';
+ len = strlen (first_unused);
+ if (len == 0) /* If we don't have a gid, it's an invalid shadow entry */
+ return 0;
pw->pw_gid = atoi (first_unused);
- room_left -= (strlen (first_unused) +1);
- first_unused += strlen (first_unused) +1;
+ room_left -= (len + 1);
+ first_unused += (len + 1);
if (NISENTRYLEN(0, 4, result) >= room_left)
goto no_more_room;
@@ -102,8 +113,9 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
NISENTRYLEN (0, 4, result));
first_unused[NISENTRYLEN (0, 4, result)] = '\0';
pw->pw_gecos = first_unused;
- room_left -= (strlen (first_unused) +1);
- first_unused += strlen (first_unused) +1;
+ len = strlen (first_unused);
+ room_left -= (len + 1);
+ first_unused += (len + 1);
if (NISENTRYLEN (0, 5, result) >= room_left)
goto no_more_room;
@@ -112,8 +124,9 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
NISENTRYLEN (0, 5, result));
first_unused[NISENTRYLEN (0, 5, result)] = '\0';
pw->pw_dir = first_unused;
- room_left -= (strlen (first_unused) +1);
- first_unused += strlen (first_unused) +1;
+ len = strlen (first_unused);
+ room_left -= (len + 1);
+ first_unused += (len + 1);
if (NISENTRYLEN (0, 6, result) >= room_left)
goto no_more_room;
@@ -122,8 +135,9 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
NISENTRYLEN (0, 6, result));
first_unused[NISENTRYLEN (0, 6, result)] = '\0';
pw->pw_shell = first_unused;
- room_left -= (strlen (first_unused) +1);
- first_unused += strlen (first_unused) +1;
+ len = strlen (first_unused);
+ room_left -= (len + 1);
+ first_unused += (len + 1);
return 1;
}
@@ -136,6 +150,7 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, struct group *gr,
size_t room_left = buflen;
char *line;
int count;
+ size_t len;
if (result == NULL)
return 0;
@@ -158,9 +173,12 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, struct group *gr,
strncpy (first_unused, NISENTRYVAL (entry, 0, result),
NISENTRYLEN (entry, 0, result));
first_unused[NISENTRYLEN (entry, 0, result)] = '\0';
+ len = strlen (first_unused);
+ if (len == 0) /* group table is corrupt */
+ return 0;
gr->gr_name = first_unused;
- room_left -= (strlen (first_unused) + 1);
- first_unused += strlen (first_unused) + 1;
+ room_left -= (len + 1);
+ first_unused += (len + 1);
if (NISENTRYLEN (entry, 1, result) >= room_left)
goto no_more_room;
@@ -169,8 +187,9 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, struct group *gr,
NISENTRYLEN (entry, 1, result));
first_unused[NISENTRYLEN (entry, 1, result)] = '\0';
gr->gr_passwd = first_unused;
- room_left -= (strlen (first_unused) + 1);
- first_unused += strlen (first_unused) + 1;
+ len = strlen (first_unused);
+ room_left -= (len + 1);
+ first_unused += (len + 1);
if (NISENTRYLEN (entry, 2, result) >= room_left)
goto no_more_room;
@@ -178,6 +197,9 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, struct group *gr,
strncpy (first_unused, NISENTRYVAL (entry, 2, result),
NISENTRYLEN (entry, 2, result));
first_unused[NISENTRYLEN (entry, 2, result)] = '\0';
+ len = strlen (first_unused);
+ if (len == 0) /* We should always have an gid */
+ return 0;
gr->gr_gid = atoi (first_unused);
room_left -= (strlen (first_unused) + 1);
first_unused += strlen (first_unused) + 1;
@@ -189,8 +211,9 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, struct group *gr,
NISENTRYLEN (entry, 3, result));
first_unused[NISENTRYLEN (entry, 3, result)] = '\0';
line = first_unused;
- room_left -= (strlen (line) + 1);
- first_unused += strlen (line) + 1;
+ len = strlen (line);
+ room_left -= (len + 1);
+ first_unused += (len + 1);
/* Adjust the pointer so it is aligned for
storing pointers. */
first_unused += __alignof__ (char *) - 1;
@@ -244,6 +267,7 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp,
{
char *first_unused = buffer;
size_t room_left = buflen;
+ size_t len;
if (result == NULL)
return 0;
@@ -267,9 +291,12 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp,
strncpy (first_unused, NISENTRYVAL (0, 0, result),
NISENTRYLEN (0, 0, result));
first_unused[NISENTRYLEN (0, 0, result)] = '\0';
+ len = strlen (first_unused);
+ if (len == 0)
+ return 0;
sp->sp_namp = first_unused;
- room_left -= (strlen (first_unused) +1);
- first_unused += strlen (first_unused) +1;
+ room_left -= (len + 1);
+ first_unused += (len + 1);
if (NISENTRYLEN (0, 1, result) >= room_left)
goto no_more_room;
@@ -278,8 +305,9 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp,
NISENTRYLEN (0, 1, result));
first_unused[NISENTRYLEN (0, 1, result)] = '\0';
sp->sp_pwdp = first_unused;
- room_left -= (strlen (first_unused) +1);
- first_unused += strlen (first_unused) +1;
+ len = strlen (first_unused);
+ room_left -= (len + 1);
+ first_unused += (len + 1);
sp->sp_lstchg = sp->sp_min = sp->sp_max = sp->sp_warn = sp->sp_inact =
sp->sp_expire = sp->sp_flag = -1;
diff --git a/nis/nss_nisplus/nisplus-pwd.c b/nis/nss_nisplus/nisplus-pwd.c
index 45c364a..194b97f 100644
--- a/nis/nss_nisplus/nisplus-pwd.c
+++ b/nis/nss_nisplus/nisplus-pwd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -25,6 +25,7 @@
#include <rpcsvc/nis.h>
#include "nss-nisplus.h"
+#include "nisplus-parser.h"
__libc_lock_define_initialized (static, lock)
@@ -32,9 +33,6 @@ static nis_result *result = NULL;
static nis_name tablename_val = NULL;
static u_long tablename_len = 0;
-extern int _nss_nisplus_parse_pwent (nis_result *res, struct passwd *pw,
- char *buffer, size_t buflen, int *errnop);
-
static enum nss_status
_nss_create_tablename (int *errnop)
{