Commit 1d4e8791 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Handle case where v6stat.zero_pos == 0 correctly.

Reported by: Kurt Roeckx <kurt@roeckx.be>, Tobias Ginzler <ginzler@fgan.de> (Debian bug #506111)
parent ae381fef
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -739,17 +739,20 @@ static int ipv6_from_asc(unsigned char *v6, const char *in)

	/* Format result */

	/* Copy initial part */
	if (v6stat.zero_pos > 0)
		{
		/* Copy initial part */
		memcpy(v6, v6stat.tmp, v6stat.zero_pos);
		/* Zero middle */
	if (v6stat.total != 16)
		memset(v6 + v6stat.zero_pos, 0, 16 - v6stat.total);
		/* Copy final part */
		if (v6stat.total != v6stat.zero_pos)
			memcpy(v6 + v6stat.zero_pos + 16 - v6stat.total,
				v6stat.tmp + v6stat.zero_pos,
				v6stat.total - v6stat.zero_pos);
		}
	else
		memcpy(v6, v6stat.tmp, 16);

	return 1;
	}