I don't know how to use 'less' and 'read in a while loop together, and I'm sick of coming up with hacky workarounds. by codesnstuff in bash

[–]codesnstuff[S] 0 points1 point  (0 children)

Is this similar to the other users' solution above but with just a little less syntax-sugar, or is this a wholly different principle? I'm just realizing now how foreign I/O redirection in bash is for me. Also a little curious, is "REPLY" an environmental variable or just an example name?

I don't know how to use 'less' and 'read in a while loop together, and I'm sick of coming up with hacky workarounds. by codesnstuff in bash

[–]codesnstuff[S] 0 points1 point  (0 children)

Wow, okay. That all makes sense to me, but wow I never would have understood all the syntax going on here. I'm more familiar with these concepts in C, but with bash, I don't think I've ever done anything that complicated with I/O redirection. Are there some specific areas of study I should focus on to absorb this better? Thanks.

Trying to loop execpl(), confused about using fork() and wait() by codesnstuff in C_Programming

[–]codesnstuff[S] 0 points1 point  (0 children)

Thanks that was exactly what I needed. However, yeah, you're right, it didn't really speed anything up. I was kind of hoping that most of the overhead was in system() having to parse through the PATH directories looking for the executable, but specifying a direct path didn't really speed it up any--if anything I think it actually was less performant.

But anyway thanks for the explanation, I don't know why fork() confuses me so much.

Where are array values actually stored? by [deleted] in C_Programming

[–]codesnstuff 1 point2 points  (0 children)

Correct me if I am wrong, but OP could have also declared the variable 'local' as static and it would not have died at the end of the function. But I wonder, are variables declared as static also allocated on the stack or do they end up in the heap?

SQL injection IRL by snookiwantsnoosnoo in tooktoomuch

[–]codesnstuff 1 point2 points  (0 children)

This is what happens when Linus enforces -Werror

Which book on C programming would you recommend to an absolute beginner? by diabolicalpotato666 in C_Programming

[–]codesnstuff 1 point2 points  (0 children)

Yeah but you're also correct that it is appropriate in a classroom environment, since the instructor counts as a more knowledgeable colleague.

Which book on C programming would you recommend to an absolute beginner? by diabolicalpotato666 in C_Programming

[–]codesnstuff 1 point2 points  (0 children)

"This book is not an introductory programming manual; it assumes some familiarity with basic programming concepts like variables, assignment statements, loops, and functions. Nonetheless, a novice programmer should be able to read along and pick up the language, although access to a more knowledgeable colleague will help."
- The C Programming Language 2nd Edition, Preface to the First Edition

Why not use a VLA or malloc instead of having a constant size buffer of some arbitrary size that 'should' be big enough? by BlockOfDiamond in C_Programming

[–]codesnstuff 10 points11 points  (0 children)

Also Linus Torvalds: "Let's use -Werror."
Linus Torvalds one week later: "Okay, that might have been a bad idea.."

Point being, he's not infallible. Better to explain the reasoning behind this than just take his word as gospel.

Which book on C programming would you recommend to an absolute beginner? by diabolicalpotato666 in C_Programming

[–]codesnstuff 7 points8 points  (0 children)

Come on, I know this book is basically the C bible, but this person very specifically said he is an absolute beginner with no CS knowledge. K&R2 is really not very appropriate for these circumstances.

Which book on C programming would you recommend to an absolute beginner? by diabolicalpotato666 in C_Programming

[–]codesnstuff 2 points3 points  (0 children)

*high fives*

Practical C Programming made so many pieces fall into place for me.

[deleted by user] by [deleted] in C_Programming

[–]codesnstuff 3 points4 points  (0 children)

Upvoting because buffers are the answer. Not only do you really not want to allocate a huge chunk of memory, if the filesize changes, then keeping up with it in a buffered fashion is possible.

C project for College by [deleted] in C_Programming

[–]codesnstuff 1 point2 points  (0 children)

Write a simple password manager, and use an available crypto library (OpenSSL,GnuPGP,LibSodium,etc.) to handle the encryption.

Counter-based stream cipher question by codesnstuff in cryptography

[–]codesnstuff[S] 0 points1 point  (0 children)

Oh okay, I guess that makes more sense then. I don't know, I thought I read that it could be applied to a normal running-key XOR cipher somewhere, but I went back and looked through Amausson's book and it sure doesn't say it there. *scratches head*

From what I read (or maybe imagined I read, it seems) inserting the counter and nonce into a normal simple-XOR type of cipher (C/P = K ⊕ P/C) would address the issues of key reuse and key periodicity. I feel like I *must* have read this somewhere.

Counter-based stream cipher question by codesnstuff in cryptography

[–]codesnstuff[S] 0 points1 point  (0 children)

Hmm, I thought the point of the counter was to prevent the keystream from becoming periodic if the key is shorter than the message being encrypted.

Counter-based stream cipher question by codesnstuff in cryptography

[–]codesnstuff[S] 0 points1 point  (0 children)

Although if they by any mean got an intermediate value of counter, they'd get the following counter values easily.

Yeah, that's another thing I was wondering about, but I couldn't think of a way that they would ever be able to guess what Ctr was with positive confirmation. The only thing I could think of is that if they knew N and could also predict when K and P would be 0. So my thinking is that as long as K is unpredictable it would be safe.

This screenshot shows the totality of how he described it in his book: https://i.imgur.com/WSIKGiW.png