Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere Programmierung(d+019) OpenGL(20.09.2026 um 15:51 Uhr)
Sichere ProgrammierungYou Released an App. Now What?(20.09.2026 um 15:52 Uhr)
Sichere Programmierung(d+023) Triangle(20.09.2026 um 15:53 Uhr)
Sichere ProgrammierungHow many coding agents are you using for the same project?(20.09.2026 um 15:57 Uhr)
Sichere ProgrammierungCapyToolkit: 45+ free browser tools, each with a how-to guide(20.09.2026 um 16:00 Uhr)
Sichere ProgrammierungDay-01: Starting My Cybersecurity Journey(20.09.2026 um 16:02 Uhr)
Sichere ProgrammierungWhat crt.sh's Error Pages Taught Me About Retry Logic(20.09.2026 um 16:03 Uhr)
Sichere ProgrammierungI taught my shell to stop me *before* I run `rm -rf /`(20.09.2026 um 16:09 Uhr)
Sichere ProgrammierungTraditional Coding vs Agentic Coding: The Flow State Problem(20.09.2026 um 16:19 Uhr)
Sichere Programmierung(d+019) OpenGL(20.09.2026 um 15:51 Uhr)
Sichere ProgrammierungYou Released an App. Now What?(20.09.2026 um 15:52 Uhr)
Sichere Programmierung(d+023) Triangle(20.09.2026 um 15:53 Uhr)
Sichere ProgrammierungHow many coding agents are you using for the same project?(20.09.2026 um 15:57 Uhr)
Sichere ProgrammierungCapyToolkit: 45+ free browser tools, each with a how-to guide(20.09.2026 um 16:00 Uhr)
Sichere ProgrammierungDay-01: Starting My Cybersecurity Journey(20.09.2026 um 16:02 Uhr)
Sichere ProgrammierungWhat crt.sh's Error Pages Taught Me About Retry Logic(20.09.2026 um 16:03 Uhr)
Sichere ProgrammierungI taught my shell to stop me *before* I run `rm -rf /`(20.09.2026 um 16:09 Uhr)
Sichere ProgrammierungTraditional Coding vs Agentic Coding: The Flow State Problem(20.09.2026 um 16:19 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

CodeSOD: If You're First

Reagiere als Erste:r — dein Feedback zählt!

Laurie has been supporting an internal application for a few years. The code is a mess, and while she wasn't at the company for the early stages of development, tales are told about it- it was chaotic, it was badly estimated, it was wildly over budget, the latter phases were a crunch where ten developers were shoved onto the project at the last second.

Today, it works- mostly. But it provides plenty of support tickets for Laurie, and demonstrates some WTFs.

One feature is that many forms have a "RESET" button. Push the button, clear out all the values on the form. Here's how that code looks:

for (var i = 0, l = document.getElementsByName("someId").length; i < l; i++) {
  if (i === 0) {
    document.getElementsByName("someId")[i].checked = false;
  } else {
    document.getElementsByName("someId")[i].checked = false;
  }
}
for (var j = 0, l1 = document.getElementsByName("someOtherId").length; j < l1; j++) {
  if (j === 0) {
    document.getElementsByName("someOtherId")[j].checked = false;
  } else {
    document.getElementsByName("someOtherId")[j].checked = false;
  }
}
for (var k = 0, l2 = document.getElementsByName("anotherId").length; k < l2; k++) {
  if (k === 0) {
    document.getElementsByName("anotherId")[k].checked = false;
  } else {
    document.getElementsByName("anotherId")[k].checked = false;
  }
}

Each of these for loops wants to iterate across a set of form fields. Now, document.getElementsByName returns an array of those fields, so we could just iterate across the elements in the array. But no, we have to keep invoking document.getElementsByName every time.

At least they didn't make that mistake about checking the length- they stored that in a variable. But, and it's a minor thing, l, l1, and l2 can look disturbingly like numbers- 12. A good font can help with that, but in a quick skim of the code, it can play a trick on the eyes.

But, of course, the real WTF here are the if statements. If we're on the first element, we uncheck the checkbox. If we're on any other element… we also uncheck the checkbox.

Why is that if statement there? Why is it repeated in every block? We can only guess, but my suspicion is that this is a case of copy/paste programming. In some other part of the application, they wanted to change the state of every box but the first. Since that code was close to what our developer wanted, they copy/pasted and made the minimal changes to make it work, without any attempt to understand the code.

Laurie refactored this block away, but there are many more like it, and there will be plenty of support work.

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten CodeSOD: If You're First

Thematisch verwandte Begriffe: CodeSOD, Youre, First · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-93956 | A flaw has been found in olivier-ls PHP-FTS up to 1.1.2. Affected by thi…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick