Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Only look within the note section for the version note.
Andrew Turner committed 12 years ago
commit f1983867e4d841cf51937bab7eb64c5c5be7d222
parent 98c4192
1 file changed +6 -1
modified libpkg/pkg_elf.c
@@ -575,13 +575,18 @@ pkg_get_myarch(char *dest, size_t sz)

	data = elf_getdata(scn, NULL);
	src = data->d_buf;
-
	while (1) {
+
	while ((uintptr_t)src < ((uintptr_t)data->d_buf + data->d_size)) {
		memcpy(&note, src, sizeof(Elf_Note));
		src += sizeof(Elf_Note);
		if (note.n_type == NT_VERSION)
			break;
		src += note.n_namesz + note.n_descsz;
	}
+
	if ((uintptr_t)src >= ((uintptr_t)data->d_buf + data->d_size)) {
+
		ret = EPKG_FATAL;
+
		pkg_emit_error("fail to find the version elf note");
+
		goto cleanup;
+
	}
	osname = src;
	src += roundup2(note.n_namesz, 4);
	if (elfhdr.e_ident[EI_DATA] == ELFDATA2MSB)