Lines Matching +full:1 +full:ms
8 * 1. Redistributions of source code must retain the above copyright
55 #define ELF_ALIGN(a) ((((a) + align - 1) / align) * align)
64 #define SIZE_UNKNOWN CAST(off_t, -1)
69 toomany(struct magic_set *ms, const char *name, uint16_t num) in toomany() argument
71 if (ms->flags & MAGIC_MIME) in toomany()
72 return 1; in toomany()
73 if (file_printf(ms, ", too many %s (%u)", name, num) == -1) in toomany()
74 return -1; in toomany()
75 return 1; in toomany()
89 retval.c[0] = tmpval.c[1]; in getu16()
90 retval.c[1] = tmpval.c[0]; in getu16()
109 retval.c[1] = tmpval.c[2]; in getu32()
110 retval.c[2] = tmpval.c[1]; in getu32()
130 retval.c[1] = tmpval.c[6]; in getu64()
135 retval.c[6] = tmpval.c[1]; in getu64()
326 #define OS_STYLE_FREEBSD 1
351 dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, in dophn_core() argument
362 if (ms->flags & MAGIC_MIME) in dophn_core()
366 if (file_printf(ms, ", no program header") == -1) in dophn_core()
367 return -1; in dophn_core()
371 if (file_printf(ms, ", corrupted program header size") == -1) in dophn_core()
372 return -1; in dophn_core()
382 if (file_printf(ms, in dophn_core()
384 (intmax_t)off) == -1) in dophn_core()
385 return -1; in dophn_core()
404 if ((bufsize = pread(fd, nbuf, len, offs)) == -1) { in dophn_core()
405 if (file_printf(ms, " can't read note section at %jd", in dophn_core()
406 (intmax_t)offs) == -1) in dophn_core()
407 return -1; in dophn_core()
414 offset = donote(ms, nbuf, offset, CAST(size_t, bufsize), in dophn_core()
427 do_note_netbsd_version(struct magic_set *ms, int swap, void *v) in do_note_netbsd_version() argument
433 if (file_printf(ms, ", for NetBSD") == -1) in do_note_netbsd_version()
434 return -1; in do_note_netbsd_version()
453 if (file_printf(ms, " %u.%u", ver_maj, ver_min) == -1) in do_note_netbsd_version()
454 return -1; in do_note_netbsd_version()
460 if (file_printf(ms, ".%u", ver_patch) == -1) in do_note_netbsd_version()
461 return -1; in do_note_netbsd_version()
464 if (file_printf(ms, "Z") == -1) in do_note_netbsd_version()
465 return -1; in do_note_netbsd_version()
468 if (file_printf(ms, "%c", 'A' + ver_rel - 1) == -1) in do_note_netbsd_version()
469 return -1; in do_note_netbsd_version()
476 do_note_freebsd_version(struct magic_set *ms, int swap, void *v) in do_note_freebsd_version() argument
482 if (file_printf(ms, ", for FreeBSD") == -1) in do_note_freebsd_version()
483 return -1; in do_note_freebsd_version()
512 if (file_printf(ms, " 4.6.2") == -1) in do_note_freebsd_version()
513 return -1; in do_note_freebsd_version()
515 if (file_printf(ms, " %d.%d", desc / 100000, in do_note_freebsd_version()
516 desc / 10000 % 10) == -1) in do_note_freebsd_version()
517 return -1; in do_note_freebsd_version()
519 if (file_printf(ms, ".%d", desc / 1000 % 10) == -1) in do_note_freebsd_version()
520 return -1; in do_note_freebsd_version()
522 if (file_printf(ms, " (%d)", desc) == -1) in do_note_freebsd_version()
523 return -1; in do_note_freebsd_version()
525 if (file_printf(ms, " %d.%d", desc / 100000, in do_note_freebsd_version()
526 desc / 10000 % 10 + desc / 1000 % 10) == -1) in do_note_freebsd_version()
527 return -1; in do_note_freebsd_version()
529 if (file_printf(ms, " (%d)", desc) == -1) in do_note_freebsd_version()
530 return -1; in do_note_freebsd_version()
532 if (file_printf(ms, ".%d", desc / 10 % 10) == -1) in do_note_freebsd_version()
533 return -1; in do_note_freebsd_version()
536 if (file_printf(ms, " %d.%d", desc / 100000, in do_note_freebsd_version()
537 desc / 1000 % 100) == -1) in do_note_freebsd_version()
538 return -1; in do_note_freebsd_version()
541 if (file_printf(ms, " (%d)", desc) == -1) in do_note_freebsd_version()
542 return -1; in do_note_freebsd_version()
544 if (file_printf(ms, ".%d", desc / 10 % 10) == -1) in do_note_freebsd_version()
545 return -1; in do_note_freebsd_version()
553 do_bid_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, in do_bid_note() argument
577 if (file_printf(ms, ", BuildID[%s]=", btype) == -1) in do_bid_note()
578 return -1; in do_bid_note()
581 if (file_printf(ms, "%02x", desc[i]) == -1) in do_bid_note()
582 return -1; in do_bid_note()
583 return 1; in do_bid_note()
588 if (file_printf(ms, ", Go BuildID=%s", in do_bid_note()
590 RCAST(const char *, &nbuf[doff]))) == -1) in do_bid_note()
591 return -1; in do_bid_note()
592 return 1; in do_bid_note()
598 do_os_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, in do_os_note() argument
606 if (file_printf(ms, ", for SuSE %d.%d", nbuf[doff], in do_os_note()
607 nbuf[doff + 1]) == -1) in do_os_note()
608 return -1; in do_os_note()
609 return 1; in do_os_note()
617 if (file_printf(ms, ", for GNU/") == -1) in do_os_note()
618 return -1; in do_os_note()
621 if (file_printf(ms, "Linux") == -1) in do_os_note()
622 return -1; in do_os_note()
625 if (file_printf(ms, "Hurd") == -1) in do_os_note()
626 return -1; in do_os_note()
629 if (file_printf(ms, "Solaris") == -1) in do_os_note()
630 return -1; in do_os_note()
633 if (file_printf(ms, "kFreeBSD") == -1) in do_os_note()
634 return -1; in do_os_note()
637 if (file_printf(ms, "kNetBSD") == -1) in do_os_note()
638 return -1; in do_os_note()
641 if (file_printf(ms, "<unknown>") == -1) in do_os_note()
642 return -1; in do_os_note()
644 if (file_printf(ms, " %d.%d.%d", elf_getu32(swap, desc[1]), in do_os_note()
645 elf_getu32(swap, desc[2]), elf_getu32(swap, desc[3])) == -1) in do_os_note()
646 return -1; in do_os_note()
647 return 1; in do_os_note()
653 if (do_note_netbsd_version(ms, swap, &nbuf[doff]) == -1) in do_os_note()
654 return -1; in do_os_note()
655 return 1; in do_os_note()
661 if (do_note_freebsd_version(ms, swap, &nbuf[doff]) in do_os_note()
662 == -1) in do_os_note()
663 return -1; in do_os_note()
664 return 1; in do_os_note()
670 if (file_printf(ms, ", for OpenBSD") == -1) in do_os_note()
671 return -1; in do_os_note()
673 return 1; in do_os_note()
680 if (file_printf(ms, ", for DragonFly") == -1) in do_os_note()
681 return -1; in do_os_note()
684 if (file_printf(ms, " %d.%d.%d", desc / 100000, in do_os_note()
685 desc / 10000 % 10, desc % 10000) == -1) in do_os_note()
686 return -1; in do_os_note()
687 return 1; in do_os_note()
696 if (file_printf(ms, ", for Android %d", api_level) == -1) in do_os_note()
697 return -1; in do_os_note()
705 if (file_printf(ms, ", built by NDK %.64s (%.64s)", in do_os_note()
706 &nbuf[doff + 4], &nbuf[doff + 4 + 64]) == -1) in do_os_note()
707 return -1; in do_os_note()
715 do_pax_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, in do_pax_note() argument
738 if (desc && file_printf(ms, ", PaX: ") == -1) in do_pax_note()
739 return -1; in do_pax_note()
742 if (((1 << CAST(int, i)) & desc) == 0) in do_pax_note()
744 if (file_printf(ms, "%s%s", did++ ? "," : "", in do_pax_note()
745 pax[i]) == -1) in do_pax_note()
746 return -1; in do_pax_note()
748 return 1; in do_pax_note()
754 do_memtag_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, in do_memtag_note() argument
777 if (desc && file_printf(ms, ", Android Memtag: ") == -1) in do_memtag_note()
778 return -1; in do_memtag_note()
781 if (((1 << CAST(int, i)) & desc) == 0) in do_memtag_note()
783 if (file_printf(ms, "%s%s", did++ ? "," : "", in do_memtag_note()
784 memtag[i]) == -1) in do_memtag_note()
785 return -1; in do_memtag_note()
787 return 1; in do_memtag_note()
793 do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, in do_core_note() argument
801 int os_style = -1; in do_core_note()
829 if (os_style != -1 && (*flags & FLAGS_DID_CORE_STYLE) == 0) { in do_core_note()
830 if (file_printf(ms, ", %s-style", os_style_names[os_style]) in do_core_note()
831 == -1) in do_core_note()
832 return -1; in do_core_note()
845 if (file_printf(ms, ", from '%.31s', pid=%u, uid=%u, " in do_core_note()
847 file_printable(ms, sbuf, sizeof(sbuf), in do_core_note()
855 elf_getu32(swap, pi.cpi_sigcode)) == -1) in do_core_note()
856 return -1; in do_core_note()
859 return 1; in do_core_note()
871 if (file_printf(ms, ", from '%.80s'", nbuf + doff + in do_core_note()
872 argoff) == -1) in do_core_note()
873 return -1; in do_core_note()
876 if (file_printf(ms, ", pid=%u", in do_core_note()
878 doff + pidoff)))) == -1) in do_core_note()
879 return -1; in do_core_note()
954 for (k = i + 1 ; k < NOFFSETS; k++) { in do_core_note()
956 int adjust = 1; in do_core_note()
983 while (cp > cname && isspace(cp[-1])) in do_core_note()
985 if (file_printf(ms, ", from '%s'", in do_core_note()
988 RCAST(char *, cname))) == -1) in do_core_note()
989 return -1; in do_core_note()
991 return 1; in do_core_note()
1004 get_offset_from_virtaddr(struct magic_set *ms, int swap, int clazz, int fd, in get_offset_from_virtaddr() argument
1017 if (file_printf(ms, in get_offset_from_virtaddr()
1019 (intmax_t)off) == -1) in get_offset_from_virtaddr()
1020 return -1; in get_offset_from_virtaddr()
1038 get_string_on_virtaddr(struct magic_set *ms, in get_string_on_virtaddr() argument
1048 offset = get_offset_from_virtaddr(ms, swap, clazz, fd, ph_off, ph_num, in get_string_on_virtaddr()
1052 (void)file_printf(ms, ", can't read elf string at %jd", in get_string_on_virtaddr()
1057 buf[buflen - 1] = '\0'; in get_string_on_virtaddr()
1072 do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, in do_auxv_note() argument
1117 file_error(ms, 0, "Too many ELF Auxv elements"); in do_auxv_note()
1118 return 1; in do_auxv_note()
1123 is_string = 1; in do_auxv_note()
1127 is_string = 1; in do_auxv_note()
1158 buflen = get_string_on_virtaddr(ms, swap, clazz, fd, in do_auxv_note()
1164 if (file_printf(ms, ", %s: '%s'", tag, buf) == -1) in do_auxv_note()
1165 return -1; in do_auxv_note()
1167 if (file_printf(ms, ", %s: %d", tag, in do_auxv_note()
1168 CAST(int, xauxv_val)) == -1) in do_auxv_note()
1169 return -1; in do_auxv_note()
1172 return 1; in do_auxv_note()
1179 dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size, in dodynamic() argument
1199 *pie = 1; in dodynamic()
1200 ms->mode |= 0111; in dodynamic()
1202 ms->mode &= ~0111; in dodynamic()
1215 donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, in donote() argument
1254 (void)file_printf(ms, ", bad note name size %#lx", in donote()
1260 (void)file_printf(ms, ", bad note description size %#lx", in donote()
1285 if (do_os_note(ms, nbuf, xnh_type, swap, in donote()
1291 if (do_bid_note(ms, nbuf, xnh_type, swap, in donote()
1297 if (do_pax_note(ms, nbuf, xnh_type, swap, in donote()
1302 if (do_memtag_note(ms, nbuf, xnh_type, swap, in donote()
1308 if (do_core_note(ms, nbuf, xnh_type, swap, in donote()
1314 if (do_auxv_note(ms, nbuf, xnh_type, swap, in donote()
1344 if (file_printf(ms, ", note=%u", xnh_type) == -1) in donote()
1354 file_printf(ms, ", %s: %s", tag, in donote()
1407 { AV_386_SSE4_1, "SSE4.1" },
1413 doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, in doshn() argument
1419 int stripped = 1, has_debug_info = 0; in doshn()
1428 if (ms->flags & MAGIC_MIME) in doshn()
1432 if (file_printf(ms, ", no section header") == -1) in doshn()
1433 return -1; in doshn()
1437 if (file_printf(ms, ", corrupted section header size") == -1) in doshn()
1438 return -1; in doshn()
1445 if (file_printf(ms, ", missing section headers at %jd", in doshn()
1446 (intmax_t)offs) == -1) in doshn()
1447 return -1; in doshn()
1453 if (file_printf(ms, ", too large section header offset %jd", in doshn()
1454 (intmax_t)name_off) == -1) in doshn()
1455 return -1; in doshn()
1462 if ((namesize = pread(fd, name, sizeof(name) - 1, offs)) in doshn()
1463 == -1) { in doshn()
1464 if (file_printf(ms, in doshn()
1466 (intmax_t)offs) == -1) in doshn()
1467 return -1; in doshn()
1472 has_debug_info = 1; in doshn()
1478 if (file_printf(ms, ", can't read elf section at %jd", in doshn()
1479 (intmax_t)off) == -1) in doshn()
1480 return -1; in doshn()
1507 if (file_printf(ms, in doshn()
1513 CAST(uintmax_t, fsize)) == -1) in doshn()
1514 return -1; in doshn()
1517 if (xsh_size > ms->elf_shsize_max) { in doshn()
1518 file_error(ms, errno, "Note section size too " in doshn()
1520 ms->elf_shsize_max); in doshn()
1521 return -1; in doshn()
1524 file_error(ms, errno, "Cannot allocate memory" in doshn()
1526 return -1; in doshn()
1532 if (file_printf(ms, in doshn()
1534 (intmax_t)offs) == -1) in doshn()
1535 return -1; in doshn()
1543 noff = donote(ms, nbuf, CAST(size_t, noff), in doshn()
1566 == CAST(off_t, -1)) { in doshn()
1567 file_badseek(ms); in doshn()
1568 return -1; in doshn()
1583 file_badread(ms); in doshn()
1584 return -1; in doshn()
1588 char *p = cbuf + 1; in doshn()
1594 if (file_printf(ms, in doshn()
1596 == -1) in doshn()
1597 return -1; in doshn()
1600 p += strlen(p) + 1; in doshn()
1605 if (tag != 1) { in doshn()
1606 if (file_printf(ms, ", unknown gnu" in doshn()
1608 == -1) in doshn()
1609 return -1; in doshn()
1627 if (file_printf(ms, in doshn()
1633 == -1) in doshn()
1634 return -1; in doshn()
1648 if (file_printf(ms, ", with debug_info") == -1) in doshn()
1649 return -1; in doshn()
1651 if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1) in doshn()
1652 return -1; in doshn()
1670 if (file_printf(ms, ", uses") == -1) in doshn()
1671 return -1; in doshn()
1675 if (file_printf(ms, in doshn()
1676 " %s", cdp->cd_name) == -1) in doshn()
1677 return -1; in doshn()
1683 if (file_printf(ms, in doshn()
1686 CAST(unsigned long long, cap_hw1)) == -1) in doshn()
1687 return -1; in doshn()
1689 if (file_printf(ms, in doshn()
1691 CAST(unsigned long long, cap_hw1)) == -1) in doshn()
1692 return -1; in doshn()
1697 if (file_printf(ms, in doshn()
1700 : ", not known to use frame pointer") == -1) in doshn()
1701 return -1; in doshn()
1705 if (file_printf(ms, in doshn()
1708 CAST(unsigned long long, cap_sf1)) == -1) in doshn()
1709 return -1; in doshn()
1721 dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, in dophn_exec() argument
1735 if (file_printf(ms, ", no program header") == -1) in dophn_exec()
1736 return -1; in dophn_exec()
1740 if (file_printf(ms, ", corrupted program header size") == -1) in dophn_exec()
1741 return -1; in dophn_exec()
1750 if (file_printf(ms, in dophn_exec()
1752 (intmax_t)off) == -1) in dophn_exec()
1753 return -1; in dophn_exec()
1764 doread = 1; in dophn_exec()
1771 if (file_printf(ms, in dophn_exec()
1773 CAST(unsigned long, align)) == -1) in dophn_exec()
1774 return -1; in dophn_exec()
1779 doread = 1; in dophn_exec()
1795 if (bufsize == -1) { in dophn_exec()
1796 if (file_printf(ms, in dophn_exec()
1798 (intmax_t)offs) == -1) in dophn_exec()
1799 return -1; in dophn_exec()
1807 dynamic = 1; in dophn_exec()
1810 ms->mode &= ~0111; in dophn_exec()
1814 offset = dodynamic(ms, nbuf, offset, in dophn_exec()
1820 if (ms->flags & MAGIC_MIME) in dophn_exec()
1826 if (ms->flags & MAGIC_MIME) in dophn_exec()
1829 nbuf[bufsize - 1] = '\0'; in dophn_exec()
1835 if (ms->flags & MAGIC_MIME) in dophn_exec()
1845 offset = donote(ms, nbuf, offset, in dophn_exec()
1853 if (ms->flags & MAGIC_MIME) in dophn_exec()
1858 if (ms->flags & MAGIC_MIME) in dophn_exec()
1868 if (file_printf(ms, ", %s linked", linking_style) == -1) in dophn_exec()
1869 return -1; in dophn_exec()
1871 if (file_printf(ms, ", interpreter %s", file_printable(ms, in dophn_exec()
1873 interp, sizeof(interp))) == -1) in dophn_exec()
1874 return -1; in dophn_exec()
1880 file_tryelf(struct magic_set *ms, const struct buffer *b) in file_tryelf() argument
1899 if (ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)) in file_tryelf()
1903 * file locations and thus file(1) cannot determine it from easily. in file_tryelf()
1917 if((lseek(fd, CAST(off_t, 0), SEEK_SET) == CAST(off_t, -1)) in file_tryelf()
1919 fd = file_pipe2file(ms, fd, buf, nbytes); in file_tryelf()
1921 if (fd == -1) { in file_tryelf()
1922 file_badread(ms); in file_tryelf()
1923 return -1; in file_tryelf()
1933 if (fstat(fd, &st) == -1) { in file_tryelf()
1934 file_badread(ms); in file_tryelf()
1935 return -1; in file_tryelf()
1959 if (file_printf(ms, ", unknown class %d", clazz) == -1) in file_tryelf()
1960 return -1; in file_tryelf()