View | Details | Raw Unified | Return to bug 215105 | Differences between
and this patch

Collapse All | Expand All

(-)lib/libc/net/linkaddr.c (-6 / +5 lines)
Lines 125-131 link_ntoa(const struct sockaddr_dl *sdl) Link Here
125
	static char obuf[64];
125
	static char obuf[64];
126
	_Static_assert(sizeof(obuf) >= IFNAMSIZ + 20, "obuf is too small");
126
	_Static_assert(sizeof(obuf) >= IFNAMSIZ + 20, "obuf is too small");
127
	char *out;
127
	char *out;
128
	const char *in, *inlim;
128
	const u_char *in, *inlim;
129
	int namelen, i, rem;
129
	int namelen, i, rem;
130
130
131
	namelen = (sdl->sdl_nlen <= IFNAMSIZ) ? sdl->sdl_nlen : IFNAMSIZ;
131
	namelen = (sdl->sdl_nlen <= IFNAMSIZ) ? sdl->sdl_nlen : IFNAMSIZ;
Lines 142-152 link_ntoa(const struct sockaddr_dl *sdl) Link Here
142
		}
142
		}
143
	}
143
	}
144
144
145
	in = (const char *)sdl->sdl_data + sdl->sdl_nlen;
145
	in = (const u_char *)sdl->sdl_data + sdl->sdl_nlen;
146
	inlim = in + sdl->sdl_alen;
146
	inlim = in + sdl->sdl_alen;
147
147
148
	while (in < inlim && rem > 1) {
148
	while (in < inlim && rem > 1) {
149
		if (in != (const char *)sdl->sdl_data + sdl->sdl_nlen) {
149
		if (in != (const u_char *)sdl->sdl_data + sdl->sdl_nlen) {
150
			*out++ = '.';
150
			*out++ = '.';
151
			rem--;
151
			rem--;
152
		}
152
		}
Lines 154-168 link_ntoa(const struct sockaddr_dl *sdl) Link Here
154
		if (i > 0xf) {
154
		if (i > 0xf) {
155
			if (rem < 3)
155
			if (rem < 3)
156
				break;
156
				break;
157
			*out++ = hexlist[i >> 4];
157
			*out++ = hexlist[i & 0xf];
158
			*out++ = hexlist[i & 0xf];
158
			i >>= 4;
159
			*out++ = hexlist[i];
160
			rem -= 2;
159
			rem -= 2;
161
		} else {
160
		} else {
162
			if (rem < 2)
161
			if (rem < 2)
163
				break;
162
				break;
164
			*out++ = hexlist[i];
163
			*out++ = hexlist[i];
165
			rem++;
164
			rem--;
166
		}
165
		}
167
	}
166
	}
168
	*out = 0;
167
	*out = 0;

Return to bug 215105