Skip to content

Commit 3b0a6f9

Browse files
committed
Remove hard-coded default for RHS
Don't fall back to using a default RHS when the configuration file can't be read and there isn't a suitable value set in the environment. Original report from https://bugzilla.redhat.com/show_bug.cgi?id=1332493
1 parent 39b21da commit 3b0a6f9

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/lib/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ noinst_PROGRAMS = hestest
1515
hestest_SOURCES = hestest.c
1616
hestest_LDADD = libhesiod.la
1717

18-
TESTS_ENVIRONMENT = ./hestest
18+
TESTS_ENVIRONMENT = HES_DOMAIN=athena.mit.edu ./hestest
1919
TESTS = hestest.conf
2020

2121
EXTRA_DIST = hesiod.conf.sample hestest.conf

src/lib/hesiod.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ static const char rcsid[] = "$Id: hesiod.c,v 1.30 2002-04-03 21:40:55 ghudson Ex
8282
#endif
8383

8484
/* Defaults if the configuration file is not present. */
85-
#define DEF_RHS ".athena.mit.edu"
8685
#define DEF_LHS ".ns"
8786

8887
/* Maximum size of a Hesiod response from the DNS. */
@@ -141,6 +140,12 @@ int hesiod_init(void **context)
141140
else
142141
errno = ENOMEM;
143142
}
143+
/* Make sure that the rhs is set. */
144+
if (!ctx->rhs)
145+
{
146+
errno = EINVAL;
147+
return -1;
148+
}
144149
else
145150
return 0;
146151
}
@@ -302,13 +307,12 @@ static int read_config_file(struct hesiod_p *ctx, const char *filename)
302307
fp = fopen(filename, "r");
303308
if (!fp)
304309
{
305-
/* Use compiled in default domain names. */
310+
/* Use compiled in default LHS. */
306311
ctx->lhs = malloc(strlen(DEF_LHS) + 1);
307-
ctx->rhs = malloc(strlen(DEF_RHS) + 1);
308-
if (ctx->lhs && ctx->rhs)
312+
ctx->rhs = NULL;
313+
if (ctx->lhs)
309314
{
310315
strcpy(ctx->lhs, DEF_LHS);
311-
strcpy(ctx->rhs, DEF_RHS);
312316
return 0;
313317
}
314318
else

0 commit comments

Comments
 (0)