mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* alternatives to null-terminated byte arrays in syscalls in the future?
@ 2016-04-08 21:04 Andrew Kelley
  2016-04-08 21:10 ` Denys Vlasenko
  2016-04-09 12:37 ` One Thousand Gnomes
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Kelley @ 2016-04-08 21:04 UTC (permalink / raw)
  To: linux-kernel

The open syscall looks like this:

SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)

filename is a null terminated byte array. Null termination is one way
to handle lengths of byte arrays, but arguably a better way is to keep
track of the length in a separate field. Many programming languages
use pointer + length instead of null termination for various reasons.

When it's time to make a syscall such as open, software which does not
have a null character at the end of byte arrays are forced to allocate
memory, do a memcpy, insert a null byte, perform the open syscall,
then deallocate the memory.

What are the chances that in the future, Linux will have alternate
syscalls which accept byte array parameters where one can pass the
length of the byte array explicitly instead of using a null byte?

Regards,
Andrew Kelley

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-09 12:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-08 21:04 alternatives to null-terminated byte arrays in syscalls in the future? Andrew Kelley
2016-04-08 21:10 ` Denys Vlasenko
2016-04-08 21:21   ` Andrew Kelley
2016-04-09 12:37 ` One Thousand Gnomes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®