Post A6BtiXbb5c15nRCDaa by impiaaa@octodon.social
(DIR) More posts by impiaaa@octodon.social
(DIR) Post #A65r4ojKdRh8T3z7Vw by SuricrasiaOnline@cybre.space
2021-04-10T05:15:25Z
10 likes, 17 repeats
here we go, the cursed computer iceberg meme: https://suricrasia.online/iceberg/
(DIR) Post #A66bfPOQOftiUYaklc by oakreef@abhlach.ie
2021-04-10T13:28:07Z
0 likes, 0 repeats
@SuricrasiaOnline I'm curious what "array[i] == i[array]" is referring to specifically but search engines are not equipped for that kind of query.
(DIR) Post #A66bfPsCbxiVyuWXBI by wolf480pl@mstdn.io
2021-04-10T14:07:20Z
1 likes, 0 repeats
@oakreef @SuricrasiaOnline in C, array[i] and i[array] are equivalent. In the end of the day, it's just *(array+i).Though I'm not sure how this is affected by element size...
(DIR) Post #A66d9kjHjVHLJ7Nkbw by grips@cawfee.club
2021-04-10T14:24:03.268484Z
0 likes, 0 repeats
@SuricrasiaOnline >floats for money is fine, actuallyTell me more.
(DIR) Post #A66dIvPROWUl2LTRB2 by grips@cawfee.club
2021-04-10T14:25:42.840048Z
0 likes, 0 repeats
@SuricrasiaOnline Oh wait, we're blocked. Sad! :blobtongue:
(DIR) Post #A66j1uD1CgvA7Fvmvg by eqe@aleph.land
2021-04-10T15:29:49Z
0 likes, 0 repeats
@wolf480pl @oakreef @SuricrasiaOnline adding 1 to a pointer increments it to point to the next item. So on x86 (or most risc) given `u32 *p = ...; u32 *q =p +1;`, p and q will differ by 4 if you cast them to intptr_t.(There are some obscure ISAs where this isn't true, but few people try to run off-the-shelf C code on those, these days. The ones I'm aware of are AS/400, Cray UNICOS, and the TI DSP families. Even on those, when they have a C compiler, the equivalency a[i] == i[a] still holds.)
(DIR) Post #A66k0GVVQd8keDMOGW by wolf480pl@mstdn.io
2021-04-10T15:40:45Z
0 likes, 0 repeats
@eqe @oakreef @SuricrasiaOnline hmm I guess if one of the things being added is an integer, there's no doubt whose element size should be taken. It's not like you're doing array1[array2]
(DIR) Post #A66m1JBNAQjT8uZHlo by eqe@aleph.land
2021-04-10T16:03:18Z
1 likes, 0 repeats
@wolf480pl @oakreef @SuricrasiaOnline yep, exactly! Lots of things in C turn into integers automatically, but not pointers.A partial list of things you can index into a C array with:Characters, tbl['a']booleans, tbl[x==3]floating point I think? tbl[sin(x)]And strings are also treated as pointers, so you can doc = "abcde"[4]Combining that with the original curséd syntax we havec = 4["abcde"]
(DIR) Post #A66t8hg5BxhCotPDzU by oakreef@abhlach.ie
2021-04-10T17:15:11Z
0 likes, 0 repeats
@eqe @wolf480pl @SuricrasiaOnline I'm afraid I'm not familiar with C so this is hard to parse for me. Most my coding experience is higher level stuff like C# and Python.I know that an asterisk indicates that you're referencing a pointer. So given a pointer p that references 32 bit unsigned integer and another pointer q that references an integer one higher than q...then you've lost me.
(DIR) Post #A66t8i4BkKyi1egTZ2 by wolf480pl@mstdn.io
2021-04-10T17:23:06Z
0 likes, 0 repeats
@oakreef @eqe @SuricrasiaOnline ok, let's say you have a function like this:```void foo(uint8_t array[]) { // ...}````array` here is actually a pointer to a chunk of memory with 8-bit unsigned ints, one after another.`*array` dereferences array, and gives you the uint8_t that the pointer points to, i.e. 0-th element of the arrayso `*array` is the same as `array[0]`1/
(DIR) Post #A66tIRiROQT6D79dWS by wolf480pl@mstdn.io
2021-04-10T17:24:53Z
0 likes, 0 repeats
@oakreef @eqe @SuricrasiaOnline now, you can get a pointer to the 1-th element by just increasing `array` by one:`ptr_to_1th = array + 1`and dereference it:`*ptr_to_1th`or just: `*(array + 1)`this is the same as `array[1]`.Now, because C treats `a[b]` as just a syntactic sugar for `*(a + b)`, `1[array]` works equally well.Now the surprising part is if you have array whose elements are bigger than 1-byte2/
(DIR) Post #A66tdc0uIio6EJsuSO by wolf480pl@mstdn.io
2021-04-10T17:28:42Z
0 likes, 0 repeats
@oakreef @eqe @SuricrasiaOnline btw. `uint8_t array[]`, when used in function arguments, is just syntactic sugar for:`uint8_t* array`i.e. a pointer to uint8_t.Now if you have an array of uint32_t like:`uint32_t array[]`or`uint32_t* array`you'd still want `array[1]` to refer to the 1th element and not 3 bytes of 0th element and 1 byte of 1th element.But C sees it as:`*(array + 1)`so here's the trick:3/
(DIR) Post #A66timiZvhsWsQmIxE by wolf480pl@mstdn.io
2021-04-10T17:29:39Z
0 likes, 0 repeats
@oakreef @eqe @SuricrasiaOnline if array is of type uint32_t*,then adding one to it advances it by sizeof(uint32_t), in this case 4.so `array+1` is 4 bytes after `array`, and all is well.Same for `1+array`.Same for `1[array]`I hope this helps.4/4
(DIR) Post #A678PHfwcSy4PWhniC by e@anime.website
2021-04-10T20:14:14.153898Z
0 likes, 0 repeats
@SuricrasiaOnline I recognize way too many of those, all the way down to the bottomwhat do I win
(DIR) Post #A67Dgf4XNrlJfTJXTU by allison@blob.cat
2021-04-10T21:13:23.318043Z
0 likes, 0 repeats
@SuricrasiaOnline not a bad attempt
(DIR) Post #A67EvzrCULCOQex5to by hyphen@anime.website
2021-04-10T21:27:22.269297Z
0 likes, 0 repeats
@e @SuricrasiaOnline same
(DIR) Post #A67NKiLxVIOH0xdVz6 by SuricrasiaOnline@cybre.space
2021-04-10T21:04:44Z
1 likes, 1 repeats
UPDATE: ALL THE ITEMS HAVE A LINK TO CONTEXT/AN EXPLAINER PAGE!!
(DIR) Post #A6BtJzqsvrtqA6dw6y by haskal@cybre.space
2021-04-13T01:40:22Z
0 likes, 0 repeats
@SuricrasiaOnline remembered oneAWAVAUATUSH
(DIR) Post #A6BtK0Mn1FQ7l3ZPqC by SuricrasiaOnline@cybre.space
2021-04-13T03:17:53Z
1 likes, 0 repeats
@haskal that's not cursed, that's simply the true name of god
(DIR) Post #A6BtiXbb5c15nRCDaa by impiaaa@octodon.social
2021-04-11T21:21:14Z
0 likes, 1 repeats
@SuricrasiaOnline you have on there an entry for the general category of hardware-damaging software ("killer poke"), but I might suggest also adding some specific high-profile examples, like stuxnet, or violently destroying an electrical generator by turning an entire power grid against it ( https://www.wired.com/story/how-30-lines-of-code-blew-up-27-ton-generator/ )
(DIR) Post #A6BvAOf62E0S7YgAzY by jautero@social.librem.one
2021-04-11T04:55:54Z
0 likes, 1 repeats
@SuricrasiaOnline Reading about "OpenOffice doesn't print on Tuesdays" reminded me of "You can't code PHP in Turkish" https://bugs.php.net/bug.php?id=18556
(DIR) Post #A6Bw2n4XUfwRSwW6ng by lanodan@queer.hacktivis.me
2021-04-13T03:49:18.149163Z
0 likes, 0 repeats
@haskal @SuricrasiaOnline That one reminded me of https://www.jwz.org/blog/2014/10/we-live-in-a-magical-future-where-strings-is-exploitable/ and dammit…
(DIR) Post #A6BwpyuOH852MhE4Qa by daniel_bohrer@chaos.social
2021-04-10T14:55:39Z
0 likes, 2 repeats
Moving online webserver using public transport:https://www.youtube.com/watch?v=vQ5MA685ApE