|
|
Message-ID: <CAPLrYEQo7Q64Z94UkZADu_pjEEs88fW6_BH9=vpC=z4kWOWjMQ@mail.gmail.com>
Date: Wed, 28 Jan 2015 10:10:53 +0100
From: Daniel Cegiełka <daniel.cegielka@...il.com>
To: musl@...ts.openwall.com
Subject: Re: getrandom syscall
2015-01-28 10:02 GMT+01:00 Szabolcs Nagy <nsz@...t70.net>:
> * Daniel Cegie??ka <daniel.cegielka@...il.com> [2015-01-27 23:12:46 +0100]:
>> #include <stddef.h>
>> #include <errno.h>
>> #include "syscall.h"
>>
>
> #ifdef SYS_getrandom
>
>> int getrandom(void *buf, size_t len)
>> {
>> int ret, pre_errno = errno;
>>
>> if (len > 256) {
>> errno = EIO;
>> return -1;
>> }
>> do {
>> ret = syscall(SYS_getrandom, buf, len, 0);
>> } while (ret == -1 && errno == EINTR);
>> if (ret != len)
>> return -1;
>> errno = pre_errno;
>> return 0;
>> }
>
> #endif
>
> eg sh does not have the syscall (linux is not consistent with
> syscalls for whatever reason)
SYS_getrandom is defined on musl, so #ifdef SYS_getrandom is not a
good solution:
http://git.musl-libc.org/cgit/musl/tree/arch/x86_64/bits/syscall.h#n657
It's better to return an error.
Daniel
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.