this post was submitted on 26 May 2026
303 points (99.7% liked)

Programmer Humor

31857 readers
1353 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 3 years ago
MODERATORS
 
top 9 comments
sorted by: hot top controversial new old
[–] Canconda@lemmy.ca 38 points 3 weeks ago (1 children)

Some Majority Report shit right here.

[–] a_jeering_serpent@sopuli.xyz 12 points 3 weeks ago

Oh my realization fuse slow burned on this. I was in to the next thing when it hit me. 10/10

[–] Kolanaki@pawb.social 21 points 3 weeks ago* (last edited 3 weeks ago)

IWonTheLottoAndThisIsAMessageToMyPastSelf

new password accepted

Fuck!

[–] snooggums@piefed.world 13 points 3 weeks ago

It matches the first password in the plain text array.

[–] Redkey@programming.dev 8 points 3 weeks ago (2 children)

I presume that the code was tested for various cases where there was at least one previous password on record, but everyone forgot about new users with no previous passwords. However I'm having trouble imagining what the code could actually be doing.

I can only imagine a dynamically typed language, and a "checkedPasswords" variable being declared but uninitialized, then a loop incrementing that variable for each non-similar password pulled from the records, and finally a check to see if checkedPasswords equals the number of stored previous passwords.

The execution environment could type and initialize the variable by default after the first increment, but in the case of the user having no previous passwords on record that wouldn't happen, and the final equivalency check would be comparing an integer to some internal "NaN" state, thus failing.

[–] squaresinger@lemmy.world 6 points 3 weeks ago (1 children)

I'd rather guess that it's the wrong error message. Like e.g. there's a communication error with a downstream service and they just catch Exception broadly and convert it to this error message. That would also explain why the non-filled value defaults to 0.

We had something similar where there was a check that checks whether the password is the same as the user name, but then it showed the "Password is too short" message to the user instead because of an overly broad try-catch.

[–] sukhmel@programming.dev 3 points 3 weeks ago

Also if the user is not yet registered, reset password shouldn't work, as there is no password to reset, maybe that's the real error. Or the counter is wrong

[–] Cethin@lemmy.zip 1 points 3 weeks ago

Isn't the most obvious just an off-by-one error? It checked the 0th position in the array of former passwords, and output the index as the output. We start at index 0 while programming for the first entry in an array.

[–] HeyThisIsntTheYMCA@lemmy.world 2 points 3 weeks ago

I just use all the leaked password databases when setting up my bullshit that's gotta work

The last time I program more than Skyrim was 2010 and skyro no work since 2015 why