mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
std.c: Fix incorrect dirent structure (#11602)
d_name is a null-terminated string, but it is not guaranteed that the last byte of the array is null.
This commit is contained in:
parent
e0a0df5a8a
commit
43373e61fa
@ -928,12 +928,12 @@ pub const Sigaction = extern struct {
|
||||
};
|
||||
|
||||
pub const dirent = extern struct {
|
||||
d_ino: usize,
|
||||
d_seekoff: usize,
|
||||
d_ino: u64,
|
||||
d_seekoff: u64,
|
||||
d_reclen: u16,
|
||||
d_namlen: u16,
|
||||
d_type: u8,
|
||||
d_name: u8, // field address is address of first byte of name
|
||||
d_name: [1024]u8,
|
||||
|
||||
pub fn reclen(self: dirent) u16 {
|
||||
return self.d_reclen;
|
||||
|
||||
@ -337,7 +337,7 @@ pub const dirent = extern struct {
|
||||
d_reclen: u16,
|
||||
d_namlen: u16,
|
||||
d_type: u8,
|
||||
d_name: [MAXNAMLEN:0]u8,
|
||||
d_name: [MAXNAMLEN + 1]u8,
|
||||
|
||||
pub fn reclen(self: dirent) u16 {
|
||||
return self.d_reclen;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user