aboutsummaryrefslogtreecommitdiff
path: root/src/inetd.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-01-08 15:31:17 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-01-08 16:17:35 +0200
commit489432d354d88049afe4af54c29965d382d67f7a (patch)
tree84725496a92564824f75f0a2edd5a595411ffab2 /src/inetd.c
parent3325fed2895f079486b88c65409c73153fec306f (diff)
downloadpies-489432d354d88049afe4af54c29965d382d67f7a.tar.gz
pies-489432d354d88049afe4af54c29965d382d67f7a.tar.bz2
Uniformly use grecs memory management functions.
* gnulib.modules: Remove unneded modules. * ident/ident.h: Remove xalloc.h, include errno.h * ident/ident.c: Use standard allocation functions instead of x* * ident/pam.c: Remove. * ident/provider.c: Remove. * ident/system.c: Remove. * src/meta.c: Remove. * src/Makefile.am: Remove meta.c * src/progman.c: Use grecs_* allocation functions instead of x*. (notify): Use wordsplit to expand variables within message. Rename variables: program-name to program_name; canonical-program-name to canonical_program_name. * doc/pies.texi: Update. * src/depmap.c: Use grecs_* allocation functions instead of x*. (depmap_end): New function. * src/diag.c (logmsg_vprintf): Use grecs_txtacc instead of obstack. * src/pies.h (depmap_end): New proto. Remove unused includes. * src/acl.c: Use grecs_* allocation functions instead of x*. * src/ctl.c: Likewise. * src/inetd.c: Likewise. * src/limits.c: Likewise. * src/meta1gram.y: Likewise. * src/meta1lex.l: Likewise. * src/pies.c: Likewise. * src/socket.c: Likewise. * src/sysvinit.c: Likewise. * src/userprivs.c: Likewise.
Diffstat (limited to 'src/inetd.c')
-rw-r--r--src/inetd.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/inetd.c b/src/inetd.c
index 4a55ad5..3eb4470 100644
--- a/src/inetd.c
+++ b/src/inetd.c
@@ -64,13 +64,13 @@ mktag (const char *address, const char *service)
if (address)
{
- str = xmalloc (strlen (address) + 1 + strlen (service) + 1);
+ str = grecs_malloc (strlen (address) + 1 + strlen (service) + 1);
strcpy (str, address);
strcat (str, ":");
strcat (str, service);
}
else
- str = xstrdup (service);
+ str = grecs_strdup (service);
return str;
}
@@ -137,7 +137,7 @@ inetd_conf_file (const char *file)
dfl_address = NULL;
else
{
- dfl_address = xmalloc (len);
+ dfl_address = grecs_malloc (len);
memcpy (dfl_address, ws.ws_wordv[IFLD_SERVICE], len-1);
dfl_address[len-1] = 0;
}
@@ -193,19 +193,25 @@ inetd_conf_file (const char *file)
}
else
{
+ char *s = NULL;
+ size_t l = 0;
+ int rc;
+
/* Create URL from protocol and service fields. */
- str = xasprintf ("inet+%s://%s:%s",
- ws.ws_wordv[IFLD_PROTOCOL],
- address ? address : "0.0.0.0",
- service);
- if (pies_url_create (&url, str))
+ if (grecs_asprintf (&s, &l, "inet+%s://%s:%s",
+ ws.ws_wordv[IFLD_PROTOCOL],
+ address ? address : "0.0.0.0",
+ service))
+ grecs_alloc_die ();
+ rc = pies_url_create (&url, s);
+ free (s);
+ if (rc)
{
/* FIXME: Better error message */
logmsg (LOG_ERR, "%s:%lu: %s",
file, line_no, _("invalid socket address"));
continue;
}
- free (str);
}
/* Parse wait/nowait field */
@@ -274,31 +280,31 @@ inetd_conf_file (const char *file)
comp->flags = flags;
if (ISCF_TCPMUX (comp->flags))
comp->tcpmux = mktag (address, "tcpmux");
- comp->service = xstrdup (service);
- comp->privs.user = xstrdup (user); /* FIXME: memory leak */
+ comp->service = grecs_strdup (service);
+ comp->privs.user = grecs_strdup (user); /* FIXME: memory leak */
if (group)
{
comp->privs.groups = grecs_list_create ();
comp->privs.groups->free_entry = listel_dispose;
- grecs_list_append (comp->privs.groups, xstrdup (group));
+ grecs_list_append (comp->privs.groups, grecs_strdup (group));
}
- comp->program = xstrdup (ws.ws_wordv[IFLD_SERVER_PATH]);
+ comp->program = grecs_strdup (ws.ws_wordv[IFLD_SERVER_PATH]);
if (ws.ws_wordc > IFLD_MIN_COUNT)
{
size_t i, j;
comp->argc = ws.ws_wordc - IFLD_MIN_COUNT;
- comp->argv = xcalloc (comp->argc + 1, sizeof (comp->argv[0]));
+ comp->argv = grecs_calloc (comp->argc + 1, sizeof (comp->argv[0]));
for (i = IFLD_SERVER_ARGS, j = 0; i < ws.ws_wordc; i++, j++)
- comp->argv[j] = xstrdup (ws.ws_wordv[i]);
+ comp->argv[j] = grecs_strdup (ws.ws_wordv[i]);
}
else
{
comp->argc = 1;
- comp->argv = xcalloc (comp->argc + 1, sizeof (comp->argv[0]));
- comp->argv[0] = xstrdup (comp->program);
+ comp->argv = grecs_calloc (comp->argc + 1, sizeof (comp->argv[0]));
+ comp->argv[0] = grecs_strdup (comp->program);
}
if (progman_lookup_component (comp->tag) == NULL)
@@ -341,7 +347,7 @@ inetd_conf_dir (const char *name)
if (name[namelen-1] != '/')
namebufsize++;
namebufsize += NAME_INIT_ALLOC;
- namebuf = xmalloc (namebufsize);
+ namebuf = grecs_malloc (namebufsize);
memcpy (namebuf, name, namelen);
if (name[namelen-1] != '/')
namebuf[namelen++] = 0;
@@ -362,7 +368,7 @@ inetd_conf_dir (const char *name)
if (namelen + len >= namebufsize)
{
namebufsize = namelen + len + 1;
- namebuf = xrealloc (namebuf, namebufsize);
+ namebuf = grecs_realloc (namebuf, namebufsize);
}
strcpy (namebuf + namelen, ent->d_name);
errs |= inetd_conf_file (namebuf);

Return to:

Send suggestions and report system problems to the System administrator.