-
twobitsahead
What would be the best way of capturing stderr from GCC? Not sure if I am understanding something incorrectly; the dev I am interacting with suggests capturing stderr from GCC by using dtrace. Has a better way been formulated since the 90s?
-
tsoome
ok, I must be blind or something, but why this buffer needs to be 32 bytes?!
src.illumos.org/source/xref/illumos…/fs/zfs/zfs_vfsops.c?r=4763305e#789
-
tsoome
I can count 17:)
-
Woodstock
uh, that looks nasty
-
Woodstock
why does it not use asprintf or expect the actual buffer size as an argument?
-
tsoome
asprintf wont work as they are skipping prefix bytes from that buffer ("obj-")
-
tsoome
that is, the actual buffer is expected to be + 4 bytes larger
-
Woodstock
then the callers should just pass the actual size, and use snprintf in that function :)
-
Woodstock
sprintf is so 1985
-
tsoome
At first I took that 32 literally and replaced char *buf by char buf[32], and gained compiler check on buffer size, then I started to look where this size is coming from:)
-
andyf
17? I count 20, or are you taking into account limits on domainid and rid?
-
andyf
well, 21 with the null byte
-
andyf
Oh, hex.. I'll get some coffee.
-
tsoome
eee? we are putting those bytes into that buf: sprintf(buf, "%llx", (longlong_t)fuid); nothing more
-
tsoome
:D
-
tsoome
yes, its hex
-
tsoome
so its 16+1
-
tsoome
and yes, going to replace sprintf by snprintf there for safety
-
andyf
That function takes a 'len' parameter in openzfs, as well as using snprintf (commit c9e319faae)
-
jclulow
tsoome: we should use ilstr for that, tbh
-
jclulow
-
tsoome
yes, that one was blowing on my face with char buf[32] like this: ../../common/fs/zfs/zfs_vfsops.c:849:15: error: 'id_to_fuidstr' accessing 32 bytes in a region of size 24 [-Werror=stringop-overflow=]
-
jclulow
oof
-
jclulow
You can still use a stack buffer with ilstr_init_prealloc() at least, it just won't be as egregiously unsafe haha
-
tsoome
and then I started to check 1) why 32, and 2) what happens with the content there
-
tsoome
I guess ilstr may be good answer there, as zfs_vfsops.c is os specific anyhow [in OpenZFS] and therefore we will not suffer the portability.
-
tsoome
ofc that 32 must be leftover from some older version;)
-
tsoome
ah, ok, quota bits are moved to zfs_quota.c ok....
-
gitomat
[illumos-gate] 16997 zfs.h correct comments in zfs_ioc -- Toomas Soome <tsoome⊙mc>
-
richlowe
I might have misread above, but I don't see reasons to avoid ilstr for porting purposes
-
richlowe
we have an interface that makes our strings safer, that's good, and we should use it
-
jclulow
richlowe: Yes, agreed.
-
jclulow
If folks want to take patches we've written against ZFS and apply them to other projects, they're welcome to them under the same licence etc
-
jclulow
(and thus also welcome to make a copy of ilstr etc)