[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1771973239227176.png (316 KB, 1080x996)
316 KB
316 KB PNG
previous: >>108361692

#define __NR_readlink            89
#define __NR_readlinkat 267

https://man7.org/linux/man-pages/man2/readlink.2.html

tl;dr:
read the contents of a symbolic link

what a disgusting syscall LMFAO
>readlink() does not append a terminating null byte to buf.
>The required size for the buffer can be obtained from the stat.st_size value returned by a call to lstat(2) on the link. However, the number of bytes written by readlink() and readlinkat() should be checked to make sure that the size of the symbolic link did not increase between the calls.
genuinely horrifying...
i don't have much else to say about this one. it's just bad

relevant resources:
man man

man syscalls

https://man7.org/linux/man-pages/
https://linux.die.net/man/
https://elixir.bootlin.com/linux/
https://elixir.bootlin.com/musl/
https://elixir.bootlin.com/glibc/
>>
>>108370984
LMAO. Who designed that shit?
>>
>>108370984
>The required size for the buffer can be obtained from the stat.st_size value returned by a call to lstat(2) on the link.
At least they're limited to a few hundred bytes, so you can just use a buffer larger than the limit.
>>
>>108371245
they are not technically limited to that
>>
>>108370984
Whats a syscall
>>
What is so horrifying about the lack of null terminator? I don't get it.
>>
>>108371460
a method to access kernel resources/apis from userspace
>>
>>108371481
use case?
>>
>>108371125
Autists who don't understand kernelland locks.
>>
>>108371473
Things like null terminators and zero indexing frighten retards.
>>
>>108371473
Tons of functions expect NUL-terminated strings. If a function doesn't write them, then you have to write them yourself. If you don't know how long the string is, and there is no reliable way to estimate the size (because locks aren't a thing in Linux-autismo land), then you have to zero out the buffer IN ITS ENTIRETY first and THEN issue the call.
>>
>>108371481
oh cool thank you!
>>
>>108371567
>then you have to zero out the buffer IN ITS ENTIRETY first
There is absolutely no reason to do this, unless you're trying to waste electricity and your user's time.
>>
>>108371607
>what's a race condition
Just be quiet.
>>
memset(str, '\0', sizeof(str));
omg make it stop make it stooopp
>>
>>108371615
>int size = readlink(path, buf, bufsiz);
>buf[size] = 0;
Only in a schizo's mind does this cause a race condition.
>>
>>108371650
Congrats, you've just thrashed a quarter of your L1 cache.
>>
>>108371662
Talent is hitting a mark others miss.
Genius is hitting a mark others don't even see.

You do neither.
>>
>>108371662
Has to be bufsz-1 or you will overflow if the link is exactly bufsz bytes. This kind of demonstrates why this interface should have probably just NUL terminated the destination buffer instead of making each caller do this dance.
>>
what is lil bro yapping about?
>>
>>108371663
more like 1% of it for 10 nano seconds
>>
>>108371685
Point taken, but it's still not a race condition.
>>
>>108371697
Don't worry, you couldn't understand it anyway. Just go play with some toy language.

>>108371700
Oops, not enough memory. Go reallocate.

Oops, not enough memory again. Go reallocate.

Oops, not enough memory again. Go reallocate.

Oops, not enough memory again. Go reallocate.

Oops, not enough memory again. Go reallocate.
>>
>>108371731
Is the 8 bit cache in the room with us right now?
>>
>>108371748
>8-bit cache
Found your problem.
>>
>>108370984
What speaks against rewriting it?
>>
simd schizo redditor out of his depth again meltie and emacs screenshot incoming
>>
>>108371731
>Oops, not enough memory again. Go reallocate.
Not an issue if you start with a big enough buffer.
>>
>>108371784
Speak English
>>
>>108371784
Hey, it's not my fault you're only alive because you technically qualify for human rights, thus making killing you illegal.
>>
bampu
>>
seems like there is more interest in fighting than in syscalls...
>>
>>108374267
This is what happens when you lay out bait for the registry schizo (if that's who this is).
At least the permissions ones tomorrow should be interesting. I predict anger at there not being enough granularity in permissions, and my issue with them that I'll mention then.
>>
>>108374308
>obvious persecution complex suggests schizophrenia
>projects it onto others
It makes so much sense now.
>>
>>108374547
>people getting sick of your bullshit
>they must have schizophrenia
Of course, there's no other explanation for this
>>
>>108374602
Yes, and there is absolutely nothing you can do about it.

Nothing.
>>
retarded OP



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.