MemSet
Description
Set memory region to a value. A zero byte count returns dst without writing to it.
Parameters
| Name | Direction | Description |
|---|---|---|
dst |
out | Destination memory region. |
val |
in | Byte value to write (low 8 bits used). |
n |
in | Number of bytes to set. |
Success
Returns destination pointer.
Failure
Aborts via LOG_FATAL when n > 0 and dst is NULL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Init.h:154:
} UNPL(_s) = {{0}, 0}; \
UNPL(_s).done == 0; \
MemSet(UNPL(_s).d, 0, sizeof(UNPL(_s).d)), UNPL(_s).done = 1) \
for (Vec(T) name = {.length = 0, \
.capacity = (ne), \
- In
Init.h:164:
*UNPL(_done) = &name; \
UNPL(_done); \
MemSet(&name, 0, sizeof(name)), UNPL(_done) = NULL)
///
- In
Init.h:234:
#define StrInitStack(name, ne) \
for (char UNPL(_d)[(ne) + 1] = {0}, *UNPL(_loop) = UNPL(_d); UNPL(_loop); \
MemSet(UNPL(_d), 0, sizeof(UNPL(_d))), UNPL(_loop) = NULL) \
for (Str name = {.length = 0, \
.capacity = (ne), \- In
Init.h:244:
*UNPL(_done) = &name; \
UNPL(_done); \
MemSet(&name, 0, sizeof(name)), UNPL(_done) = NULL)
///
- In
Insert.h:29:
if (!map->key_copy_init) {
MemSet(key_src, 0, key_size);
}- In
Insert.h:33:
if (!map->value_copy_init) {
MemSet(value_src, 0, value_size);
}- In
Insert.h:41:
static inline bool map_zero_value_source_on_success(GenericMap *map, void *value_src, size value_size, bool success) {
if (success && !map->value_copy_init) {
MemSet(value_src, 0, value_size);
}- In
Budget.h:203:
"BudgetAllocatorInit: buffer too small for bitmap + one padded slot" \
), \
MemSet( \
PTR_ALIGN_UP_POW2((buf_ptr), 8u), \
0, \
__attribute__((used)) void *memset(void *dst, int c, freestanding_size_t n) {
MemSet(dst, c, (size)n);
return dst;
} # if !PLATFORM_WINDOWS
__attribute__((used)) void bzero(void *dst, freestanding_size_t n) {
MemSet(dst, 0, (size)n);
}
# endif- In
Memory.c:73:
}
void *MemSet(void *dst, i32 val, size n) {
if (n == 0) {
return dst;- In
Str.c:142:
clone_allocator = alloc ? (Allocator *)alloc : src->allocator;
MemSet(dst, 0, sizeof(Str));
*dst = StrInit(clone_allocator);
dst->copy_init = src->copy_init;- In
Vec.c:51:
}
} else {
MemSet(vec->data, 0, item_size * (vec->capacity + 1));
}- In
Vec.c:60:
// __magic at the next validate call instead of silently dispatching
// into freed pointers.
MemSet(vec, 0, sizeof(*vec));
}- In
Vec.c:73:
}
} else {
MemSet(vec->data, 0, item_size * (vec->capacity + 1));
}
}- In
Vec.c:104:
}
vec->data = (char *)ptr;
MemSet(ptr + old_capacity * item_size, 0, item_size * (n + 1 - old_capacity));
vec->capacity = n;
MAGIC_MARK_DIRTY(vec);- In
Vec.c:229:
for (size i = 0; i < count; i++) {
if (vec->copy_init) {
MemSet(vec_ptr_at(vec, idx + i, item_size), 0, item_size);
if (!vec->copy_init(vec_ptr_at(vec, idx + i, item_size), item_data + i * item_size, vec->allocator)) {
for (size s = 0; s < inserted_count; s++) {- In
Vec.c:235:
}
MemSet(vec_ptr_at(vec, idx, item_size), 0, count * item_size);
if (idx < vec->length) {
MemMove(- In
Vec.c:242:
(vec->length - idx) * item_size
);
MemSet(vec_ptr_at(vec, vec->length, item_size), 0, count * item_size);
}- In
Vec.c:255:
vec->length += count;
MemSet(vec_ptr_at(vec, vec->length, item_size), 0, item_size);
return true;
}- In
Vec.c:302:
for (size i = 0; i < count; i++) {
if (vec->copy_init) {
MemSet(vec_ptr_at(vec, idx + i, item_size), 0, item_size);
if (!vec->copy_init(vec_ptr_at(vec, idx + i, item_size), item_data + i * item_size, vec->allocator)) {
for (size s = 0; s < inserted_count; s++) {- In
Vec.c:316:
}
MemSet(vec_ptr_at(vec, vec->length, item_size), 0, item_size * count);
return false;
}- In
Vec.c:327:
vec->length += count;
MemSet(vec_ptr_at(vec, vec->length, item_size), 0, item_size);
return true;
}- In
Vec.c:357:
}
} else {
MemSet(vec_ptr_at(vec, start, item_size), 0, count * item_size);
}
}- In
Vec.c:369:
(vec->length - start - count) * item_size
);
MemSet(vec_ptr_at(vec, (vec->length - count), item_size), 0, count * item_size);
vec->length -= count;- In
Vec.c:373:
vec->length -= count;
MemSet(vec_ptr_at(vec, vec->length, item_size), 0, item_size);
}- In
Vec.c:399:
}
} else {
MemSet(vec_ptr_at(vec, start, item_size), 0, count * item_size);
}
}- In
Vec.c:421:
}
MemSet(vec_ptr_at(vec, vec->length - count, item_size), 0, count * item_size);
vec->length -= count;- In
Vec.c:427:
// Keep the post-length sentinel slot zeroed so VecBegin-returned arrays
// are safe to treat as NUL-terminated where the element type allows.
MemSet(vec_ptr_at(vec, vec->length, item_size), 0, item_size);
}- In
Vec.c:503:
if (vec->data) {
MemSet(vec_ptr_at(vec, vec->length, item_size), 0, item_size);
}- In
Map.c:213:
}
MemSet(map_entry_ptr(map, entry_size, idx), 0, entry_size);
}- In
Map.c:232:
void *dst_val = entry + value_offset;
MemSet(entry, 0, entry_size);
if (map->key_copy_init) {- In
Map.c:239:
map->key_copy_deinit(dst_key, map->allocator);
}
MemSet(entry, 0, entry_size);
return false;
}- In
Map.c:254:
map->key_copy_deinit(dst_key, map->allocator);
}
MemSet(entry, 0, entry_size);
return false;
}- In
Map.c:456:
AllocatorFree(map->allocator, map->states);
MemSet(map, 0, sizeof(*map));
}- In
Map.c:1146:
}
MemSet(dst_value, 0, value_size);
if (map->value_copy_init) {- In
Map.c:1179:
}
MemSet(map_entry_ptr(map, entry_size, idx), 0, entry_size);
map->states[idx] = MAP_SLOT_TOMBSTONE;
map->length -= 1;- In
Graph.c:124:
graph->copy_deinit(data, graph->allocator);
} else {
MemSet(data, 0, item_size);
}- In
Graph.c:465:
deinit_vec(GENERIC_VEC(&graph->pending_edge_removals), sizeof(GraphPendingEdgeRemoval));
MemSet(graph, 0, sizeof(*graph));
}- In
Graph.c:618:
if (node_id && !graph->copy_init) {
MemSet(item_data, 0, item_size);
}- In
Int.c:572:
}
MemSet(bytes, 0, bytes_to_copy);
for (u64 i = 0; i < bytes_to_copy; i++) {- In
Int.c:626:
}
MemSet(bytes, 0, bytes_to_copy);
for (u64 i = 0; i < bytes_to_copy; i++) {- In
List.c:21:
clear_list(list, item_size);
MemSet(list, 0, sizeof(*list));
}- In
List.c:124:
MemCopy((u8 *)removed_data + c * item_size, node->data, item_size);
MemSet(node->data, 0, item_size);
AllocatorFree(list->allocator, node->data);
node->data = NULL;- In
List.c:136:
list->copy_deinit(node->data, list->allocator);
} else {
MemSet(node->data, 0, item_size);
}- In
BitVec.c:116:
AllocatorFree(bitvec->allocator, bitvec->data);
}
MemSet(bitvec, 0, sizeof(*bitvec));
}- In
BitVec.c:123:
bitvec->length = 0;
if (bitvec->data && bitvec->byte_size > 0) {
MemSet(bitvec->data, 0, bitvec->byte_size);
}
}- In
BitVec.c:140:
if (new_bytes > old_bytes) {
MemSet(bitvec->data + old_bytes, 0, new_bytes - old_bytes);
}- In
BitVec.c:172:
if (new_byte_size > bitvec->byte_size) {
MemSet(new_data + bitvec->byte_size, 0, new_byte_size - bitvec->byte_size);
}- In
BitVec.c:1010:
// Zero first so the OR-in loop below can leave 0-bits implicit.
MemSet(bytes, 0, bytes_to_copy);
for (u64 i = 0; i < bv->length && i / 8 < bytes_to_copy; i++) {- In
Arena.c:130:
// unconditionally on the in-chunk path.
if (zeroed) {
MemSet(out, 0, padded);
}
result = out;- In
Arena.c:334:
chunk = next;
}
MemSet(self, 0, sizeof(*self));
}- In
Debug.c:245:
DebugRecord rec;
MemSet(&rec, 0, sizeof(rec));
rec.requested_size = bytes;
rec.padded_size = padded;- In
Debug.c:498:
// `self->page` was never used and has no live state to release.
MemSet(self, 0, sizeof(*self));
}- In
Budget.c:154:
void *slot = self->slots + (size)idx * self->slot_size;
if (zeroed)
MemSet(slot, 0, self->slot_size);
#if FEATURE_ALLOC_STATS
// bytes_in_use tracks slot_size (what budget_allocator_deallocate
- In
Budget.c:255:
// The caller still owns `buf`; just wipe our header so any
// post-deinit dispatch trips ValidateAllocator on zero __magic.
MemSet(self, 0, sizeof(*self));
}- In
Page.c:347:
page_table_remove_sorted_at(self->free_entries, &self->free_len, hit);
if (zeroed) {
MemSet(ptr, 0, rounded);
}
result = ptr;- In
Page.c:529:
os_page_unmap(&self->base, self->free_entries, self->free_entries_bytes);
}
MemSet(self, 0, sizeof(*self));
}- In
Slab.c:296:
void *slot = (u8 *)self->slabs[i] + ((size)slot_idx << self->slot_size_shift);
if (zeroed) {
MemSet(slot, 0, self->slot_size);
}
#if FEATURE_ALLOC_STATS- In
Slab.c:329:
void *slot = self->slabs[idx];
if (zeroed) {
MemSet(slot, 0, self->slot_size);
}
#if FEATURE_ALLOC_STATS- In
Slab.c:449:
);
}
MemSet(self, 0, sizeof(*self));
}- In
Heap.c:737:
heap->retention_bytes -= (u64)total;
if (zeroed)
MemSet(ptr, 0, total);
} else {
ptr = os_page_map(&heap->base, total);- In
Heap.c:813:
effective = heap_class_size[cls];
if (zeroed) {
MemSet(out, 0, effective);
}
}- In
Heap.c:1125:
if (self->recycle)
os_page_unmap(&self->base, self->recycle, os_page_round_up((size)self->recycle_cap * sizeof(void *)));
MemSet(self, 0, sizeof(*self));
}
ResolverCacheEntry entry;
MemSet(&entry, 0, sizeof(entry));
entry.path = path;
if (!ElfOpen(&entry.elf, path, self->allocator)) { LOG_FATAL("SymbolResolverInit: NULL argument");
}
MemSet(out, 0, sizeof(*out));
out->allocator = alloc;
out->cache = VecInitT(out->cache, alloc); if (!ProcMapsLoad(&out->maps, alloc)) {
VecDeinit(&out->cache);
MemSet(out, 0, sizeof(*out));
return false;
} VecDeinit(&self->cache);
ProcMapsDeinit(&self->maps);
MemSet(self, 0, sizeof(*self));
} if (!self || !out)
return false;
MemSet(out, 0, sizeof(*out));
u64 addr = (u64)runtime_addr;- In
PdbCache.c:101:
}
PdbCacheEntry entry;
MemSet(&entry, 0, sizeof(entry));
if (!StrTryInitFromCstr(&entry.module_path, module_path, ZstrLen(module_path), self->allocator)) {- In
PdbCache.c:130:
}
VecDeinit(&self->entries);
MemSet(self, 0, sizeof(*self));
}- In
Dns.c:314:
return false;
}
MemSet(out, 0, sizeof(*out));
out->allocator = alloc;
out->hosts = VecInitT(out->hosts, alloc);- In
Backtrace.c:201:
ULONG64 sym_buf[(sizeof(SYMBOL_INFO) + MAX_NAME + sizeof(ULONG64) - 1) / sizeof(ULONG64)];
SYMBOL_INFO *sym = (SYMBOL_INFO *)sym_buf;
MemSet(sym, 0, sizeof(*sym));
sym->SizeOfStruct = sizeof(SYMBOL_INFO);
sym->MaxNameLen = MAX_NAME;- In
Backtrace.c:206:
IMAGEHLP_LINE64 line;
MemSet(&line, 0, sizeof(line));
line.SizeOfStruct = sizeof(line);- In
Socket.c:368:
// the right field for each platform.
static void fill_socket_addr_from_sockaddr(SocketAddr *out, const struct sockaddr *sa, u32 len) {
MemSet(out, 0, sizeof(*out));
if (len > (u32)SOCKET_ADDR_MAX_SIZE) {
len = (u32)SOCKET_ADDR_MAX_SIZE;- In
Socket.c:385:
LOG_FATAL("SocketAddrParse: out is NULL");
}
MemSet(out, 0, sizeof(*out));
if (!spec) {- In
Socket.c:413:
if (parse_ipv4(host_data, v4)) {
struct sockaddr_in *sa = (struct sockaddr_in *)out->raw;
MemSet(out, 0, sizeof(*out));
sa->sin_family = AF_INET;
sa->sin_port = FROM_BIG_ENDIAN2(port);- In
Socket.c:424:
if (parse_ipv6(host_data, v6)) {
struct sockaddr_in6 *sa = (struct sockaddr_in6 *)out->raw;
MemSet(out, 0, sizeof(*out));
sa->sin6_family = AF_INET6;
sa->sin6_port = FROM_BIG_ENDIAN2(port);- In
Socket.c:444:
LOG_FATAL("SocketAddrParse: out is NULL");
}
MemSet(out, 0, sizeof(*out));
if (!spec) {- In
Socket.c:747:
LOG_FATAL("ListenerOpen: NULL argument");
}
MemSet(out, 0, sizeof(*out));
out->fd = SOCKET_FD_INVALID;- In
Socket.c:804:
LOG_FATAL("ListenerLocalAddr: NULL argument");
}
MemSet(out, 0, sizeof(*out));
u8 buf[SOCKET_ADDR_MAX_SIZE];
u32 len = (u32)sizeof(buf);- In
Socket.c:818:
LOG_FATAL("ListenerAccept: NULL argument");
}
MemSet(out_conn, 0, sizeof(*out_conn));
out_conn->fd = SOCKET_FD_INVALID;- In
Socket.c:841:
plat_close(self->fd);
}
MemSet(self, 0, sizeof(*self));
self->fd = SOCKET_FD_INVALID;
}- In
Socket.c:853:
LOG_FATAL("SocketConnect: NULL argument");
}
MemSet(out, 0, sizeof(*out));
out->fd = SOCKET_FD_INVALID;- In
Socket.c:901:
plat_close(self->fd);
}
MemSet(self, 0, sizeof(*self));
self->fd = SOCKET_FD_INVALID;
}- In
MachoCache.c:47:
}
MachoCacheEntry entry;
MemSet(&entry, 0, sizeof(entry));
if (!StrTryInitFromCstr(&entry.module_path, module_path, ZstrLen(module_path), self->allocator)) {- In
MachoCache.c:144:
}
VecDeinit(&self->entries);
MemSet(self, 0, sizeof(*self));
}- In
Mutex.c:93:
# error "MutexDeinit: unsupported platform/architecture (no direct-syscall path)"
#endif
MemSet(m, 0, sizeof(Mutex));
}- In
Proc.c:462:
#endif
}
MemSet(proc, 0, sizeof(*proc));
}- In
Pe.c:511:
}
Buf taken = *in;
MemSet(in, 0, sizeof(*in));
MemSet(out, 0, sizeof(*out));- In
Pe.c:513:
MemSet(in, 0, sizeof(*in));
MemSet(out, 0, sizeof(*out));
out->data = taken;
// Initialize the sections vec up-front so PeDeinit on a
- In
Pe.c:574:
BufDeinit(&self->data);
VecDeinit(&self->sections);
MemSet(self, 0, sizeof(*self));
}- In
DwarfInfo.c:523:
LOG_FATAL("DwarfFunctionsBuildFromSlices: NULL argument");
}
MemSet(out, 0, sizeof(*out));
out->allocator = alloc;
out->entries = VecInitT(out->entries, alloc);- In
DwarfInfo.c:635:
if (!ok) {
DwarfFunctionsDeinit(out);
MemSet(out, 0, sizeof(*out));
}- In
DwarfInfo.c:685:
if (StrAllocator(&self->string_pool))
StrDeinit(&self->string_pool);
MemSet(self, 0, sizeof(*self));
}- In
Dns.c:180:
rec->target = StrInit(alloc);
rec->rdata = VecInitT(rec->rdata, alloc);
MemSet(rec->ipv4, 0, sizeof(rec->ipv4));
MemSet(rec->ipv6, 0, sizeof(rec->ipv6));- In
Dns.c:181:
rec->rdata = VecInitT(rec->rdata, alloc);
MemSet(rec->ipv4, 0, sizeof(rec->ipv4));
MemSet(rec->ipv6, 0, sizeof(rec->ipv6));
if (!decode_name(it, &rec->name)) {- In
Dns.c:274:
return false;
}
MemSet(out, 0, sizeof(*out));
out->answers = VecInitT(out->answers, alloc);
out->authority = VecInitT(out->authority, alloc);- In
Pdb.c:702:
}
Buf taken = *in;
MemSet(in, 0, sizeof(*in));
MemSet(out, 0, sizeof(*out));- In
Pdb.c:704:
MemSet(in, 0, sizeof(*in));
MemSet(out, 0, sizeof(*out));
out->data = taken;
out->functions = VecInitT(out->functions, BufAllocator(&taken));- In
Pdb.c:774:
VecDeinit(&self->functions);
BufDeinit(&self->data);
MemSet(self, 0, sizeof(*self));
}- In
ProcMaps.c:229:
LOG_FATAL("ProcMapsLoad: NULL argument");
}
MemSet(out, 0, sizeof(*out));
out->raw = StrInit(alloc);
out->entries = VecInitT(out->entries, alloc);- In
ProcMaps.c:260:
LOG_FATAL("ProcMapsLoadFrom: NULL argument");
}
MemSet(out, 0, sizeof(*out));
out->raw = StrInit(alloc);
out->entries = VecInitT(out->entries, alloc);- In
ProcMaps.c:280:
LOG_FATAL("ProcMapsLoadFrom: NULL argument");
}
MemSet(out, 0, sizeof(*out));
out->raw = StrInit(alloc);
out->entries = VecInitT(out->entries, alloc);- In
ProcMaps.c:299:
StrDeinit(&self->raw);
VecDeinit(&self->entries);
MemSet(self, 0, sizeof(*self));
}- In
Http.c:25:
StrDeinit(&header->key);
StrDeinit(&header->value);
MemSet(header, 0, sizeof(*header));
}- In
Http.c:33:
StrDeinit(&header->key);
StrDeinit(&header->value);
MemSet(header, 0, sizeof(*header));
}- In
Http.c:193:
StrDeinit(&req->url);
VecDeinit(&req->headers);
MemSet(req, 0, sizeof(*req));
}- In
Http.c:503:
StrDeinit(&response->body);
VecDeinit(&response->headers);
MemSet(response, 0, sizeof(*response));
}
static bool parse_cie(BufIter *body, u64 cie_offset, DwarfCie *out) {
MemSet(out, 0, sizeof(*out));
out->offset = cie_offset; DwarfFde *out
) {
MemSet(out, 0, sizeof(*out));
out->offset = (u64)(body_start - section_data);
out->cie_offset = cie_offset; LOG_FATAL("DwarfCfiBuildFromElf: NULL argument");
}
MemSet(out, 0, sizeof(*out));
out->allocator = alloc;
out->cies = VecInitT(out->cies, alloc); VecDeinit(&self->cies);
VecDeinit(&self->fdes);
MemSet(self, 0, sizeof(*self));
}
static void cfi_vm_init(CfiVm *vm, const DwarfCie *cie, u64 fde_pc_begin, u8 ra_reg) {
MemSet(vm, 0, sizeof(*vm));
vm->row.return_address_register = ra_reg;
vm->location = fde_pc_begin;- In
MachO.c:180:
}
MachoSegment seg;
MemSet(&seg, 0, sizeof(seg));
// Must-precondition for the next two moves: `cmdsize >=
// SEG64_CMD_SIZE_MIN` (checked above) reserves the 8-byte prefix
- In
MachO.c:221:
BufIter sec_it = IterCarve(cmd, SECT64_SIZE);
MachoSection sec;
MemSet(&sec, 0, sizeof(sec));
MemCopy(sec.section, IterDataAt(&sec_it, IterIndex(&sec_it)), 16);
sec.section[16] = '\0';- In
MachO.c:424:
}
Buf taken = *in;
MemSet(in, 0, sizeof(*in));
MemSet(out, 0, sizeof(*out));- In
MachO.c:426:
MemSet(in, 0, sizeof(*in));
MemSet(out, 0, sizeof(*out));
out->data = taken;
out->segments = VecInitT(out->segments, BufAllocator(&taken));- In
MachO.c:481:
VecDeinit(&self->sections);
VecDeinit(&self->symbols);
MemSet(self, 0, sizeof(*self));
}- In
Elf.c:483:
}
Buf taken = *in;
MemSet(in, 0, sizeof(*in));
MemSet(out, 0, sizeof(*out));- In
Elf.c:485:
MemSet(in, 0, sizeof(*in));
MemSet(out, 0, sizeof(*out));
out->data = taken;
out->sections = VecInitT(out->sections, BufAllocator(&taken));- In
Elf.c:546:
VecDeinit(&self->symbols);
VecDeinit(&self->dynamic_symbols);
MemSet(self, 0, sizeof(*self));
}- In
Dwarf.c:92:
// directory / file tables are walked separately by collect_cu_strings.
static bool decode_line_program_header(BufIter *cur, LineProgHeader *out) {
MemSet(out, 0, sizeof(*out));
u32 unit_length = 0;- In
Dwarf.c:288:
static void lnp_reset(LnpState *st, bool default_is_stmt) {
MemSet(st, 0, sizeof(*st));
st->file = 1;
st->line = 1;- In
Dwarf.c:303:
) {
DwarfLineEntry e;
MemSet(&e, 0, sizeof(e));
e.address = st->address;
e.line = st->line;- In
Dwarf.c:544:
LOG_FATAL("DwarfLinesBuildFromElf: NULL argument");
}
MemSet(out, 0, sizeof(*out));
out->allocator = alloc;
out->entries = VecInitT(out->entries, alloc);- In
Dwarf.c:663:
VecDeinit(&self->entries);
StrDeinit(&self->string_pool);
MemSet(self, 0, sizeof(*self));
}- In
Convert.c:1553:
Int value = IntFrom(0x0102, &alloc.base);
u8 buf[4];
MemSet(buf, 0xAA, sizeof(buf));
u64 written = IntToBytesBE(&value, buf, sizeof(buf));- In
Budget.c:150:
static bool test_alignment_honored(void) {
static u8 buf[1024];
MemSet(buf, 0, sizeof(buf));
BudgetAllocator bp = BudgetAllocatorInitAligned(buf, sizeof(buf), sizeof(int), 64);
Allocator *alloc = ALLOCATOR_OF(&bp);- In
Remove.c:111:
// Create a buffer to store the removed characters
char buffer[6];
MemSet(buffer, 0, sizeof(buffer));
// Remove a range of characters
- In
PdbCache.c:118:
static void build_pe_blob(Zstr pdb_path) {
MemSet(pe_blob, 0, sizeof(pe_blob));
pe_blob[0] = 'M';- In
PdbCache.c:201:
// even though PdbOpen itself still succeeds.
static void build_pdb_blob_va(Zstr func_name, u32 sec_va, u32 func_rva, bool match_guid) {
MemSet(pdb_blob, 0, sizeof(pdb_blob));
// Compute S_PUB32 record size based on function name length.
- In
PdbCache.c:720:
// A sidecar that exists on disk but is NOT a valid PDB (no MSF magic).
u8 junk[256];
MemSet(junk, 0xAB, sizeof(junk));
bool wrote = write_file(pe_path, pe_blob, sizeof(pe_blob)) && write_file(pdb_path, junk, sizeof(junk));- In
Socket.c:1041:
bool test_sk3_listener_unspec_family_fails(void) {
SocketAddr bad;
MemSet(&bad, 0, sizeof(bad)); // family = SOCKET_FAMILY_UNSPEC
Listener listener;- In
MachoCache.c:80:
static u64 build_macho_image(u8 *out, const u8 uuid[16], const SymSpec *syms, u32 nsyms) {
MemSet(out, 0, BLOB_CAP);
// Compute placement.
- In
MachoCache.c:335:
static u64 mc_build_macho_image(u8 *out, const u8 uuid[16], const McSymSpec *syms, u32 nsyms) {
MemSet(out, 0, MC_BLOB_CAP);
u32 seg_off = MC_HDR_SIZE;- In
MachoCache.c:476:
// their file offsets.
static u64 mc_build_dwarf_dsym(u8 *out, const u8 uuid[16], u64 low, u64 high_off, Zstr fn_name) {
MemSet(out, 0, MC_BLOB_CAP);
// ncmds: __TEXT segment (1 sect), LC_SYMTAB (0 syms), LC_UUID,
- In
MachoCache.c:495:
};
u8 strbuf[256];
MemSet(strbuf, 0, sizeof(strbuf));
u64 name_len = ZstrLen(fn_name);
MemCopy(&strbuf[MC_NAME_STRP], fn_name, name_len);- In
MachoCache.c:572:
for (u32 i = 0; i < 3; ++i) {
u8 *s = &out[dwarf_seg_off + MC_SEG64_HDR + i * MC_SECT64_SIZE];
MemSet(&s[0], 0, 16);
u32 j = 0;
while (dsects[i].name[j]) {- In
MachoCache.c:947:
static u64 bl_build_stripped_main(u8 *out, const u8 uuid[16]) {
MemSet(out, 0, BL_BLOB_CAP);
u32 seg_off = BL_HDR_SIZE; // abbrev entries, corrupting the abbrev table.
static u64 bl_build_dwarf_dsym(u8 *out, const u8 uuid[16], u64 low, u64 high_off, Zstr fn_name) {
MemSet(out, 0, BL_BLOB_CAP);
u32 text_seg_off = BL_HDR_SIZE; };
u8 strbuf[256];
MemSet(strbuf, 0, sizeof(strbuf));
u64 name_len = ZstrLen(fn_name);
MemCopy(&strbuf[BL_NAME_STRP], fn_name, name_len); for (u32 i = 0; i < 3; ++i) {
u8 *s = &out[dwarf_seg_off + BL_SEG64_HDR + i * BL_SECT64_SIZE];
MemSet(&s[0], 0, 16);
u32 j = 0;
while (dsects[i].name[j]) {- In
Pe.c:79:
static void build_pe_blob(void) {
MemSet(blob, 0, sizeof(blob));
// --- DOS header --------------------------------------------------------
- In
Pe.c:183:
// directory of one entry, and a single CodeView (RSDS) record.
static void build_pe_blob_m1(void) {
MemSet(blob, 0, sizeof(blob));
blob[0] = 'M';- In
Pe.c:275:
static const u64 PE32_IMAGE_BASE = 0x00400000ull;
static void build_pe32_blob(void) {
MemSet(blob, 0, sizeof(blob));
blob[0] = 'M';- In
Pe.c:536:
u8 garbage[256];
MemSet(garbage, 0, sizeof(garbage));
garbage[0] = 'X';
garbage[1] = 'X';- In
Pe.c:1263:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[2];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".text\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1270:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 2);- In
Pe.c:1297:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[2];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".a\0\0\0\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1306:
u32 total = SECTION_TBL_OFF + 2u * SECTION_ENTSIZE;
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 2);- In
Pe.c:1327:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[1];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, "ABCDEFGH", 8); // all 8 bytes used
secs[0].va = 0x1000;- In
Pe.c:1332:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 1);- In
Pe.c:1354:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[2];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".a\0\0\0\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1364:
u32 total = SECTION_TBL_OFF + SECTION_ENTSIZE + 20;
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 2);- In
Pe.c:1385:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[2];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".a\0\0\0\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1398:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 2);- In
Pe.c:1424:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[1];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".a\0\0\0\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1432:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 1);- In
Pe.c:1460:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[1];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".a\0\0\0\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1471:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 1);- In
Pe.c:1496:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[1];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".a\0\0\0\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1503:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 1);- In
Pe.c:1529:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[2];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".text\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1537:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 2);- In
Pe.c:1571:
SecDesc secs[2];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".text\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1578:
u8 blob[BLOB_SIZE];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 2);- In
Pe.c:1609:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[1];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".a\0\0\0\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1614:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 1);
blob[NT_OFF] = 'Q'; // corrupt the 'P' of "PE\0\0" -> fails after DOS
- In
Pe.c:1642:
SecDesc secs[1];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".text\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1647:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 1);- In
Pe.c:1688:
u8 junk[256];
MemSet(junk, 0, sizeof(junk));
junk[0] = 'X';
junk[1] = 'Y';- In
Pe.c:1726:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[1];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".a\0\0\0\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1731:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 1);- In
Pe.c:1746:
DefaultAllocator alloc = DefaultAllocatorInit();
SecDesc secs[1];
MemSet(secs, 0, sizeof(secs));
MemCopy(secs[0].name, ".a\0\0\0\0\0\0", 8);
secs[0].va = 0x1000;- In
Pe.c:1751:
u8 blob[BLOB_CAP];
MemSet(blob, 0, sizeof(blob));
build_blob(blob, secs, 1);
blob[1] = 'X'; // 'MZ' -> 'MX'
- In
Pdb.c:57:
static void build_msf_blob(void) {
MemSet(blob, 0, sizeof(blob));
// --- Superblock (page 0) -------------------------------------------------
- In
Pdb.c:125:
u8 garbage[256];
MemSet(garbage, 0xCC, sizeof(garbage));
Pdb pdb;- In
Pdb.c:179:
static void build_full_pdb_blob(void) {
MemSet(fblob, 0, sizeof(fblob));
// Directory size: 4 (count) + N_STREAMS*4 (sizes) + block_id_count*4
- In
Pdb.c:356:
static void build_multi_pdb_blob(u32 *out_symrec_size) {
MemSet(mblob, 0, sizeof(mblob));
// --- SymRecord stream (#4): three out-of-order publics --------------
- In
Pdb.c:491:
u8 buf[256];
MemSet(buf, 0, sizeof(buf));
MemCopy(buf, kMagic, 32);
wr_u32(&buf[32], 333); // bogus block size
- In
Pdb.c:575:
// Build the full blob; returns nothing. `p` describes the DBI stream.
static void build_blob_m1(const DbiParams *p) {
MemSet(gblob, 0, sizeof(gblob));
const u32 dir_bytes = 4 + D1_NUM_STREAMS * 4 + 4 * 4; // 44
- In
Pdb.c:618:
// OptionalDbgHeader) with `filler` so any mis-located read lands on a
// recognisable, invalid SectionHdr index (0xFF -> 0xFFFF).
MemSet(dbi + 64, p->filler, (p->optdbg_off > 64 ? p->optdbg_off - 64 : 0) + p->optdbg_size + 16);
wr_u32(&dbi[0], 0xFFFFFFFFu); // VersionSignature = -1
- In
Pdb.c:857:
// bytes so its reconstructed content is identifiable.
static u32 build_blob_m2(u32 bs, const u32 *sizes, u32 n, u32 *out_dir_bytes, u32 *out_num_pages) {
MemSet(g_blob, 0, sizeof(g_blob));
// How many content pages? One per non-empty stream.
- In
Pdb.c:898:
// Fill the content page with a recognizable pattern.
u8 *content = &g_blob[data_page * bs];
MemSet(content, (u8)(0xA0 + i), sizes[i] < bs ? sizes[i] : bs);
bid_idx += 1;
data_page += 1;- In
Pdb.c:915:
static u32 build_blob_multiblock(const u32 *sizes, u32 n) {
const u32 bs = B_BS;
MemSet(g_blob, 0, sizeof(g_blob));
g_mb_blockid_count = 0;- In
Pdb.c:958:
g_mb_blockids[g_mb_blockid_count++] = data_page;
// Fill each page with a recognizable pattern.
MemSet(&g_blob[data_page * bs], (u8)(0xA0 + i), bs);
bid_idx += 1;
data_page += 1;- In
Pdb.c:1028:
u8 buf[256];
MemSet(buf, 0, sizeof(buf));
MemCopy(buf, kMagic, 32);
wr_u32(&buf[32], 256);- In
Pdb.c:1076:
u8 buf[55]; // one short of the 56-byte superblock
MemSet(buf, 0, sizeof(buf));
MemCopy(buf, kMagic, 32);
wr_u32(&buf[32], B_BS);- In
Pdb.c:1178:
static void build_two_block_dir(void) {
MemSet(g_tblob, 0, sizeof(g_tblob));
MemCopy(g_tblob, kMagic, 32);- In
Pdb.c:1194:
// Build the directory bytes contiguously, then split across pages.
u8 dir[T_DIR_BYTES];
MemSet(dir, 0, sizeof(dir));
wr_u32(&dir[0], T_NUM_STREAMS);
// All streams empty except stream 1, which has a single block.
- In
Pdb.c:1209:
// Stream 1 content.
MemSet(&g_tblob[T_DATA_PG * T_BS], 0x5A, T_DATA_SIZE);
}- In
Pdb.c:1386:
Z_DIR = 4
};
MemSet(g_blob, 0, sizeof(g_blob));
MemCopy(g_blob, kMagic, 32);
wr_u32(&g_blob[32], Z_BS);- In
Pdb.c:1484:
Allocator *base = ALLOCATOR_OF(&alloc);
MemSet(g_hblob, 0, sizeof(g_hblob));
MemCopy(g_hblob, kMagic, 32);
wr_u32(&g_hblob[32], H_BS);- In
Pdb.c:1649:
static void build_filter_blob(void) {
MemSet(g_blob_filter, 0, sizeof(g_blob_filter));
u8 *sym = &g_blob_filter[G_SYMREC_PAGE * G_BLOCK_SIZE];- In
Pdb.c:1713:
static void build_sect_blob(void) {
MemSet(g_blob_sect, 0, sizeof(g_blob_sect));
u8 *sym = &g_blob_sect[G_SYMREC_PAGE * G_BLOCK_SIZE];- In
Pdb.c:1770:
static void build_oob_seg_blob(void) {
MemSet(g_blob_oob, 0, sizeof(g_blob_oob));
u8 *sym = &g_blob_oob[G_SYMREC_PAGE * G_BLOCK_SIZE];- In
Pdb.c:1825:
static void build_size_blob(void) {
MemSet(g_blob_size, 0, sizeof(g_blob_size));
u8 *sym = &g_blob_size[G_SYMREC_PAGE * G_BLOCK_SIZE];- In
Pdb.c:1890:
static void build_sort_blob(void) {
MemSet(g_blob_sort, 0, sizeof(g_blob_sort));
u8 *sym = &g_blob_sort[G_SYMREC_PAGE * G_BLOCK_SIZE];- In
Pdb.c:1953:
static void build_mal_blob(void) {
MemSet(g_blob_mal, 0, sizeof(g_blob_mal));
u8 *sym = &g_blob_mal[G_SYMREC_PAGE * G_BLOCK_SIZE];- In
Pdb.c:2011:
static void build_ovf_blob(void) {
MemSet(g_blob_ovf, 0, sizeof(g_blob_ovf));
u8 *sym = &g_blob_ovf[G_SYMREC_PAGE * G_BLOCK_SIZE];- In
Pdb.c:2120:
// function record straddling the 512-byte block boundary.
static void build_crossblock_blob(void) {
MemSet(xblob, 0, sizeof(xblob));
// Fill the decoy gap page (9) and unused regions with a distinctive
- In
Pdb.c:2125:
// 0xEE pattern so an accidental over-read of page 8 into page 9
// would corrupt the straddling record's tail.
MemSet(&xblob[9 * X_BLOCK_SIZE], 0xEE, X_BLOCK_SIZE);
// Directory: 4 (count) + 6*4 (sizes) + 5 block ids * 4.
- In
Pdb.c:2197:
// halves into the two non-adjacent pages.
u8 sym_flat[X_SYM_SIZE];
MemSet(sym_flat, 0, sizeof(sym_flat));
// Records are packed contiguously from offset 0 so the walker never
- In
Pdb.c:2304:
// the info-stream read fail.
static void build_info_blob(u32 info_block_id) {
MemSet(sblob, 0, sizeof(sblob));
MemCopy(sblob, kMagic, 32);- In
Pdb.c:2490:
u8 junk[256];
MemSet(junk, 0xCC, sizeof(junk)); // bad magic
if (FileWriteAndClose(X_TMP_JUNK, junk, (u64)sizeof(junk)) < 0) {
DefaultAllocatorDeinit(&alloc);- In
Pdb.c:2584:
u16 symrec_stream_override
) {
MemSet(blob, 0, P5_BLOB_SIZE);
// --- SectionHdr stream (#5) ---------------------------------------
- In
Pdb.c:2884:
static Blob build_blob(u32 bs, const u32 *sizes, u32 n, u32 dir_bytes_override) {
Blob b;
MemSet(&b, 0, sizeof(b));
MemSet(g_buf, 0, sizeof(g_buf));
b.bytes = g_buf;- In
Pdb.c:2885:
Blob b;
MemSet(&b, 0, sizeof(b));
MemSet(g_buf, 0, sizeof(g_buf));
b.bytes = g_buf;
b.bs = bs;- In
Pdb.c:3064:
};
u32 sizes[N];
MemSet(sizes, 0, sizeof(sizes));
sizes[1] = 28;
sizes[3] = 76;- In
ProcMaps.c:318:
DebugAllocator alloc = DebugAllocatorInit();
ProcMaps pm;
MemSet(&pm, 0, sizeof(pm));
pm.raw = StrInit(ALLOCATOR_OF(&alloc));
pm.entries = VecInitT(pm.entries, ALLOCATOR_OF(&alloc));- In
MachO.c:75:
static void build_macho_blob(void) {
MemSet(blob, 0, sizeof(blob));
// --- Mach header (32 bytes) -------------------------------------------
- In
MachO.c:253:
static u64 build_seg_with_sections(u8 *buf, u32 nsects) {
u32 cmdsize = (u32)(SEG64_HDR + nsects * SECT64_SIZE);
MemSet(buf, 0, HDR_SIZE + cmdsize);
put_header(buf, 1, cmdsize);- In
MachO.c:285:
static u64 build_symbol_blob(const u64 *values, u32 nsyms) {
MemSet(g_symblob, 0, sizeof(g_symblob));
u32 seg_off = HDR_SIZE;- In
MachO.c:408:
u8 fat[64];
MemSet(fat, 0, sizeof(fat));
wr_u32(&fat[0], 0xCAFEBABEu);- In
MachO.c:469:
u8 buf[64];
MemSet(buf, 0, sizeof(buf));
wr_u32(&buf[0], 0xFEEDFACEu); // MH_MAGIC_32
bool ok = macho_rejects(buf, sizeof(buf));- In
MachO.c:473:
bool ok = macho_rejects(buf, sizeof(buf));
MemSet(buf, 0, sizeof(buf));
wr_u32(&buf[0], 0xCFFAEDFEu); // MH_CIGAM_64 (byte-swapped 64-bit)
ok = ok && macho_rejects(buf, sizeof(buf));- In
MachO.c:477:
ok = ok && macho_rejects(buf, sizeof(buf));
MemSet(buf, 0, sizeof(buf));
wr_u32(&buf[0], 0xDEADBEEFu); // not a Mach-O at all
ok = ok && macho_rejects(buf, sizeof(buf));- In
MachO.c:646:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
SymCfg cfg = {.buf_size = BUF, .symoff = 0x100, .nsyms = 1, .stroff = 0x110, .strsize = 16};
build_scaffold(b, &cfg);- In
MachO.c:674:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
SymCfg cfg = {.buf_size = BUF, .symoff = 0x100, .nsyms = 0, .stroff = 0x110, .strsize = 0};
build_scaffold(b, &cfg);- In
MachO.c:699:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
// strtab: \0 "alpha" \0 "beta" \0 (alpha at 1, beta at 7)
u32 stroff = 0x120;- In
MachO.c:736:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
SymCfg cfg = {.buf_size = BUF, .symoff = 0x100, .nsyms = 1, .stroff = 0x110, .strsize = 16};
build_scaffold(b, &cfg);- In
MachO.c:763:
}; // 288
u8 b[BUF];
MemSet(b, 0, sizeof(b));
u32 stroff = 0x100;
u32 strsize = 16;- In
MachO.c:790:
}; // 288
u8 b[BUF];
MemSet(b, 0, sizeof(b));
u32 symoff = 0x100; // nlist at 0x100..0x110
u32 strsize = 16;- In
MachO.c:826:
u32 BUF = stroff + strsize + 16;
u8 b[0x300]; // must cover BUF (=544 here); 0x200 overflowed
MemSet(b, 0, sizeof(b));
SymCfg cfg = {.buf_size = BUF, .symoff = symoff, .nsyms = NSY, .stroff = stroff, .strsize = strsize};
build_scaffold(b, &cfg);- In
MachO.c:856:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
u32 symoff = 0x100;
u32 stroff = 0x130; // within buffer
- In
MachO.c:884:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
u32 symoff = 0x100;
u32 strsize = 16;- In
MachO.c:912:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
u32 symoff = 0x100;
u32 stroff = 0x110;- In
MachO.c:944:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
u32 symoff = 0x100;
u32 stroff = 0x110;- In
MachO.c:974:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
u32 symoff = 0x100;
u32 stroff = 0x110;- In
MachO.c:1007:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
SymCfg cfg = {.buf_size = BUF, .symoff = 0x100, .nsyms = 0, .stroff = 0x110, .strsize = 0};
build_scaffold(b, &cfg);- In
MachO.c:1043:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
// mach_header_64
- In
MachO.c:1123:
u8 buf[HDR_SIZE];
MemSet(buf, 0, sizeof(buf));
put_header(buf, 0, 0); // ncmds = 0, sizeofcmds = 0
- In
MachO.c:1145:
u8 buf[HDR_SIZE + SEG64_HDR];
MemSet(buf, 0, sizeof(buf));
put_header(buf, 1, SEG64_HDR);- In
MachO.c:1182:
u8 buf[HDR_SIZE + SEG64_HDR];
MemSet(buf, 0, sizeof(buf));
put_header(buf, 1, SEG64_HDR);- In
MachO.c:1236:
u8 buf[HDR_SIZE + SEG64_HDR + SECT64_SIZE];
MemSet(buf, 0, sizeof(buf));
put_header(buf, 1, SEG64_HDR + SECT64_SIZE);- In
MachO.c:1277:
// exactly 32 + 72 = 104.
u8 buf[HDR_SIZE + SEG64_HDR];
MemSet(buf, 0, sizeof(buf));
put_header(buf, 1, SEG64_HDR);- In
MachO.c:1311:
u8 buf[HDR_SIZE + 8];
MemSet(buf, 0, sizeof(buf));
put_header(buf, 1, 8); // one command, sizeofcmds == 8
- In
MachO.c:1415:
u8 buf[HDR_SIZE + SEG64_HDR];
MemSet(buf, 0, sizeof(buf));
put_header(buf, 1, SEG64_HDR);
u8 *seg = &buf[HDR_SIZE];- In
MachO.c:1458:
// Bad magic (not a Mach-O), but enough bytes to read successfully.
u8 garbage[64];
MemSet(garbage, 0, sizeof(garbage));
wr_u32(&garbage[0], 0xDEADBEEFu);- In
MachO.c:1493:
// rejects after decode_header succeeds.
u8 buf[HDR_SIZE + 16];
MemSet(buf, 0, sizeof(buf));
put_header(buf, 1, 16);
u8 *lc = &buf[HDR_SIZE];- In
MachO.c:1529:
};
u8 b[BUF];
MemSet(b, 0, sizeof(b));
// mach_header_64: one load command (the LC_UUID), sizeofcmds = 24.
- In
Elf.c:155:
static void build_elf_blob(void) {
MemSet(elf_blob, 0, sizeof(elf_blob));
// --- ELF header -------------------------------------------------------
- In
Elf.c:618:
static void build_dbg_blob(void) {
MemSet(dbg_blob, 0, sizeof(dbg_blob));
// --- ELF header -------------------------------------------------------
- In
Elf.c:945:
bool test_el1_strtab_unterminated_name_is_empty(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
MemSet(elf_blob, 0, sizeof(elf_blob));
// Minimal valid header.
- In
Elf.c:1010:
bool test_el1_strtab_nul_at_size_boundary_is_empty(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
MemSet(elf_blob, 0, sizeof(elf_blob));
elf_blob[0] = 0x7f;- In
Elf.c:1069:
bool test_el1_strtab_forward_scan_name(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
MemSet(elf_blob, 0, sizeof(elf_blob));
elf_blob[0] = 0x7f;- In
Elf.c:1237:
// image flips the mutant.
static void build_min64(u8 *b) {
MemSet(b, 0, 64);
b[0] = 0x7f;
b[1] = 'E';- In
Elf.c:1545:
static void build_sym_blob(void) {
MemSet(sym_blob, 0, sizeof(sym_blob));
wr_ehdr(sym_blob, (u16)ELF_TYPE_EXEC, SF_SHT_OFF, SF_N_SECTIONS, SF_SEC_SHSTRTAB);- In
Elf.c:1871:
static void build_bid_blob(const u8 *note_payload, u32 note_size, u64 note_off_override) {
MemSet(bid_blob, 0, sizeof(bid_blob));
wr_ehdr(bid_blob, (u16)ELF_TYPE_DYN, BID_SHT_OFF, BID_N_SECTIONS, BID_SEC_SHSTRTAB);- In
Elf.c:2032:
static void build_dl_blob(const u8 *payload, u32 dl_size, u64 off_override) {
MemSet(dl_blob, 0, sizeof(dl_blob));
wr_ehdr(dl_blob, (u16)ELF_TYPE_DYN, DL_SHT_OFF, DL_N_SECTIONS, DL_SEC_SHSTRTAB);- In
Elf.c:2065:
// payload: "abc.debug\0" (10) padded to 12, then 4-byte crc -> 16 bytes
u8 payload[16];
MemSet(payload, 0, sizeof(payload));
const char fname[] = "abc.debug";
MemCopy(payload, fname, sizeof(fname)); // includes NUL
- In
Elf.c:2115:
DefaultAllocator alloc = DefaultAllocatorInit();
u8 payload[16];
MemSet(payload, 0, sizeof(payload)); // base[0] == '\0' -> empty name
wr_u32(&payload[12], 0x01020304u);
build_dl_blob(payload, 16, 0);- In
Elf.c:2136:
DefaultAllocator alloc = DefaultAllocatorInit();
u8 payload[16];
MemSet(payload, 0, sizeof(payload));
const char fname[] = "abc.debug";
MemCopy(payload, fname, sizeof(fname));- In
Elf.c:2209:
};
u8 blob[BLOB_LEN];
MemSet(blob, 0, sizeof(blob));
wr_ehdr_exec(blob, SHOFF, SHNUM, /*shstrndx=*/0);- In
Elf.c:2230:
// sections; pass the "good" defaults for a valid image.
static void build_dbg(u8 *blob, u64 note_off, u64 note_size, u64 dl_off, u64 dl_size) {
MemSet(blob, 0, DBG_BLOB_SIZE);
wr_ehdr_exec(blob, DBG_SHT_OFF, DBG_N_SEC, DBG_SEC_SHSTRTAB);
blob[16] = (u8)ELF_TYPE_DYN; // e_type low byte (DYN); harmless cosmetic
- In
Elf.c:2446:
};
u8 buf[FSIZE];
MemSet(buf, 0, sizeof(buf));
bl_wr_header(buf, SHT_OFF, NSEC, 1);- In
Dwarf.c:498:
// .shstrtab, .debug_line) and return total length into `*out_len`.
static void build_elf_with_debug_line(u8 *elf, u64 *out_len, const u8 *dl, u64 dl_len) {
MemSet(elf, 0, 4096);
// shstrtab content: "\0.shstrtab\0.debug_line\0"
static const char shstr[] = "\0.shstrtab\0.debug_line";- In
Dwarf.c:963:
// --- Shared 8192-ELF builder + lines_from_debug_line (Mutants3 & Mutants5) ---
static void build_elf_with_debug_line_8192(u8 *elf, u64 *out_len, const u8 *dl, u64 dl_len) {
MemSet(elf, 0, 8192);
static const char shstr[] = "\0.shstrtab\0.debug_line";
const u32 shstrtab_name_off = 1;- In
Dwarf.c:1954:
// declared operand count of 2; the rest 0.
u8 std_lengths[19];
MemSet(std_lengths, 0, sizeof(std_lengths));
// indices 0..11 -> opcodes 1..12
static const u8 base12[12] = {0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1};- In
Dwarf.c:2005:
// opcode_base = 15 -> 14 std_opcode_lengths entries (opcodes 1..14).
u8 std_lengths[14];
MemSet(std_lengths, 0, sizeof(std_lengths));
static const u8 base12[12] = {0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1};
for (u32 i = 0; i < 12; ++i)
Last updated on