Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

AFAIK Linux doesn't use zero-terminated strings anywhere in its syscalls, or at least not in those like write, where you pass a size alongside the buffer.


However (almost?) all syscalls dealing with filesystem paths take null-terminated strings. See for example the implementation of the open() syscall:

https://github.com/torvalds/linux/blob/fb65d872d7a8dc629837a...

(Hence the need for the strncpy_from_user()-function: https://github.com/torvalds/linux/blob/fb65d872d7a8dc629837a...)


Ahh, I totally missed the path arguments, my bad.


write() syscall writes a sequence of bytes (not string) therefore cannot use zero-terminated convention.


open takes a NUL-terminated filename.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: