Feed aggregator
AI Code Generators Are Writing Vulnerable Software Nearly Half the Time, Analysis Finds
Read more of this story at Slashdot.
JPMorgan Spooks Fintechs With Plans To Charge For Access To Customer Data
Read more of this story at Slashdot.
Only 27% of Managers Worldwide Feel Engaged at Work
Read more of this story at Slashdot.
Zuckerberg Says Meta's AI Systems Have Begun Improving Themselves, And Developing Superintelligence is Now in Sight
Read more of this story at Slashdot.
Google Execs Say Employees Have To 'Be More AI-Savvy'
Read more of this story at Slashdot.
Famous Double-Slit Experiment Holds Up When Stripped To Its Quantum Essentials
Read more of this story at Slashdot.
A Pill for Sleep Apnea Could Be on the Horizon
Read more of this story at Slashdot.
CodeSOD: Going on a teDa
Carlos G found some C++ that caused him psychic harm, and wanted to know how it ended up that way. So he combed through the history. Let's retrace the path with him.
Here was the original code:
void parseExpiryDate (const char* expiryDate) { // expiryDate is in "YYMM" format int year, month; sscanf(expiryDate, "%2d%2d", &year, &month); //... }This code takes a string containing an expiry date, and parses it out. The sscanf function is given a format string describing two, two digit integers, and it stores those values into the year and month variables.
But oops! The expiry date is actually in a MMYY format. How on earth could we possibly fix this? It can't be as simple as just swapping the year and month variables in the sscanf call, can it? (It is.) No, it couldn't be that easy. (It is.) I can't imagine how we would solve this problem. (Just swap them!)
void parseExpiryDate(const char* expiryDate) { // expiryDate is in "YYMM" format but, in some part of the code, it is formatted to "MMYY" int year, month; char correctFormat[5]; correctFormat[0] = expiryDate[2]; correctFormat[1] = expiryDate[3]; correctFormat[2] = expiryDate[0]; correctFormat[3] = expiryDate[1]; correctFormat[4] = '\0'; sscanf(correctFormat, "%2d%2d", &year, &month); //... }There we go! That was easy! We just go, character by character, and shift the order around and copy it to a new string, so that we format it in YYMM.
The comment here is a wonderful attempt at CYA. By the time this function is called, the input is in MMYY, so that's the relevant piece of information to have in the comment. But the developer really truly believed that YYMM was the original input, and thus shifts blame for the original version of this function to "some part of the code" which is shifting the format around on them, thus justifying… this trainwreck.
Carlos replaced it with:
void parseExpiryDate (const char* expiryDate) { // expiryDate is in "MMYY" format int month, year; sscanf(expiryDate, "%2d%2d", &month, &year); //... } .comment { border: none; } [Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.India's One-Airline State
Read more of this story at Slashdot.
Cheyenne To Host Massive AI Datacenter Using More Electricity Than All Wyoming Homes Combined
Read more of this story at Slashdot.
Apple's iOS 26 Text Filters Could Cost Political Campaigns Millions of Dollars
Read more of this story at Slashdot.
YouTube Rolls Out Age-Estimation Tech To Identify US Teens, Apply Additional Protections
Read more of this story at Slashdot.
Minnesota Activates National Guard After St. Paul Cyberattack
Read more of this story at Slashdot.
Linux 6.16 Brings Faster File Systems, Improved Confidential Memory Support, and More Rust Support
Read more of this story at Slashdot.
Jack Dorsey's Bluetooth Messaging App Bitchat Now On App Store
Read more of this story at Slashdot.
Cisco Donates the AGNTCY Project to the Linux Foundation
Read more of this story at Slashdot.
ChatGPT's New Study Mode Is Designed To Help You Learn, Not Just Give Answers
Read more of this story at Slashdot.
EPA Moves To Repeal Finding That Allows Climate Regulation
Read more of this story at Slashdot.
Opera Accuses Microsoft of Anti-Competitive Edge Tactics
Read more of this story at Slashdot.
Google Failed To Warn 10 Million of Turkey Earthquake Severity
Read more of this story at Slashdot.