#ident "$Id$"
-#include <sys/types.h>
-#include <stdio.h>
#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
#include "atoi/getnum.h"
#include "defines.h"
* compilation glarp to improve on this in the future.
*/
struct passwd *
-sgetpwent(const char *buf)
+sgetpwent(const char *s)
{
+ static char *pwdbuf = NULL;
static struct passwd pwent;
- static char pwdbuf[PASSWD_ENTRY_MAX_LENGTH];
int i;
char *cp;
char *fields[NFIELDS];
- /*
- * Copy the string to a static buffer so the pointers into
- * the password structure remain valid.
- */
-
- if (strlen (buf) >= sizeof pwdbuf) {
- fprintf (shadow_logfd,
- "%s: Too long passwd entry encountered, file corruption?\n",
- shadow_progname);
- return NULL; /* fail if too long */
- }
- strcpy (pwdbuf, buf);
+ free(pwdbuf);
+ pwdbuf = strdup(s);
+ if (pwdbuf == NULL)
+ return NULL;
/*
* Save a pointer to the start of each colon separated
#include <stddef.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
* sgetspent - convert string in shadow file format to (struct spwd *)
*/
struct spwd *
-sgetspent(const char *string)
+sgetspent(const char *s)
{
- static char spwbuf[PASSWD_ENTRY_MAX_LENGTH];
+ static char *spwbuf = NULL;
static struct spwd spwd;
char *fields[FIELDS];
char *cp;
int i;
- /*
- * Copy string to local buffer. It has to be tokenized and we
- * have to do that to our private copy.
- */
+ free(spwbuf);
+ spwbuf = strdup(s);
+ if (spwbuf == NULL)
+ return NULL;
- if (strlen (string) >= sizeof spwbuf) {
- fprintf (shadow_logfd,
- "%s: Too long passwd entry encountered, file corruption?\n",
- shadow_progname);
- return NULL; /* fail if too long */
- }
- strcpy (spwbuf, string);
stpsep(spwbuf, "\n");
/*