* Nulls in scalar parameters
@ 2022-10-21 4:50 Clinton Bunch
2022-10-21 10:33 ` Roman Perepelitsa
0 siblings, 1 reply; 2+ messages in thread
From: Clinton Bunch @ 2022-10-21 4:50 UTC (permalink / raw)
To: zsh-workers
I'm working on a zsh/random module and I'm creating a builtin that
returns a user-specified number of random bytes and either prints it or
returns it in a parameter. There exists a small possibility of embedded
nulls in the output, and I'm not sure how to handle setting such a value
in a parameter.
One solution is to make it return a hex string, but I'm not sure of the
utility of such a result.
Metafy looks like it would handle the null problem, but I'm not sure
what else it does nor how that would play out if printed to a file.
P.S. to be clear, this module would return random data drawn from the
kernel's entropy pool, rather than a predictable pseudo-random generator
like rand or erand48
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Nulls in scalar parameters
2022-10-21 4:50 Nulls in scalar parameters Clinton Bunch
@ 2022-10-21 10:33 ` Roman Perepelitsa
0 siblings, 0 replies; 2+ messages in thread
From: Roman Perepelitsa @ 2022-10-21 10:33 UTC (permalink / raw)
To: Clinton Bunch; +Cc: zsh-workers
On Fri, Oct 21, 2022 at 6:51 AM Clinton Bunch <cdb_zsh@zentaur.org> wrote:
>
> I'm working on a zsh/random module and I'm creating a builtin that
> returns a user-specified number of random bytes and either prints it or
> returns it in a parameter. There exists a small possibility of embedded
> nulls in the output, and I'm not sure how to handle setting such a value
> in a parameter.
This is how bin_sysread does it in system.c.
setsparam(outvar, metafy(inbuf, count, META_DUP));
`outvar` points to the name of the parameter (e.g., "REPLY"). `inbuf`
points data and `count` is the number of bytes in it.
Roman.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-21 10:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 4:50 Nulls in scalar parameters Clinton Bunch
2022-10-21 10:33 ` Roman Perepelitsa
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).