[net.bugs.4bsd] Should network aliases name be defaulted to network number?

ber@enea.UUCP (Bjorn Eriksen) (07/24/84)

Subject: Should network aliases name be defaulted to network number?
Index:	/usr/src/lib/libc/getnetent.c 4.2BSD

Description:
	When the network name data base file /etc/networks is read
	with getnetent the aliases field is defaulted to the network
	number. The manual page doesn't say it should, so I think
	it's a bug.
Repeat-By:
	Try the following and compare the two last columns (at least
	for "simple" network numbers, otherwise p->n_net has to be
	converted):

	#include <netdb.h>

	main()
	{
		register struct netent *p;
		register char **cp;

		setnetent(0);
		while (p = getnetent()) {
			printf("%s %d ", p->n_name, p->n_net);
			for (cp = p->n_aliases; *cp != 0; cp++)
				printf(" %s", *cp);
			printf("\n");
		}
		endnetent();
	}
Fix:
	In getnetent.c just before the aliases field is beeing
	extracted there are the lines

		if ( p != NULL )
			cp = p;

	which will changes "cp" only if there really are any aliases.
	Otherwise "cp" will still point to the network number, which
	then will be set to the aliases name. Why not just remove
	the "if" line?

--------
	Bjorn Eriksen
	ENEA DATA Sweden
	UUCP: {decvax,philabs}!mcvax!enea!ber