Feed aggregator
It Could Be a $250 Billion Market, But Almost No One Is Interested
Read more of this story at Slashdot.
India Court Orders Proton Mail Block On Security Grounds
Read more of this story at Slashdot.
Bitcoin Mining Costs Surge Beyond Profitability Threshold
Read more of this story at Slashdot.
Reddit Issuing 'Formal Legal Demands' Against Researchers Who Conducted Secret AI Experiment on Users
Read more of this story at Slashdot.
Government Hackers Are Leading the Use of Attributed Zero-Days, Google Says
Read more of this story at Slashdot.
Fired Disney Employee Gets 3 Years in Prison For Hacking and Changing Menus
Read more of this story at Slashdot.
OpenBSD 7.7 Released
Read more of this story at Slashdot.
Amazon To Display Tariff Costs For Consumers, Report Says
Read more of this story at Slashdot.
OpenAI-Microsoft Alliance Fractures as AI Titans Chart Separate Paths
Read more of this story at Slashdot.
Amazon Launches First Kuiper Internet Satellites
Read more of this story at Slashdot.
CodeSOD: The Wrong Kind of Character
Today's code, at first, just looks like using literals instead of constants. Austin sends us this C#, from an older Windows Forms application:
if (e.KeyChar == (char)4) { // is it a ^D? e.Handled = true; DoStuff(); } else if (e.KeyChar == (char)7) { // is it a ^g? e.Handled = true; DoOtherStuff(); } else if (e.KeyChar == (char)Keys.Home) { e.Handled = true; SpecialGoToStart(); } else if (e.KeyChar == (char)Keys.End) { e.Handled = true; SpecialGoToEnd(); }Austin discovered this code when looking for a bug where some keyboard shortcuts didn't work. He made some incorrect assumptions about the code- first, that they were checking for a KeyDown or KeyUp event, a pretty normal way to check for keyboard shortcuts. Under that assumption, a developer would compare the KeyEventArgs.KeyCode property against an enum- something like e.KeyCode == Keys.D && Keys.Control, for a CTRL+D. That's clearly not what's happening here.
No, here, they used the KeyPressEvent, which is meant to represent the act of typing. That gives you a KeyPressEventArgs with a KeyChar property- because again, it's meant to represent typing text not keyboard shortcuts. They used the wrong event type, as it won't tell them about modifier keys in use, or gracefully handle the home or end keys. KeyChar is the ASCII character code of the key press: which, in this case, CTRL+D is the "end of transmit" character in ASCII (4), and CTRL+G is the goddamn bell character (7). So those two branches work.
But home and end don't have ASCII code points. They're not characters that show up in text. They get key codes, which represent the physical key pressed, not the character of text. So (char)Keys.Home isn't really a meaningful operation. But the enum is still a numeric value, so you can still turn it into a character- it just turns into a character that emphatically isn't the home key. It's the "$". And Keys.End turns into a "#".
It wasn't very much work for Austin to move the event handler to the correct event type, and switch to using KeyCodes, which were both more correct and more readable.
[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.Car Subscription Features Raise Your Risk of Government Surveillance, Police Records Show
Read more of this story at Slashdot.
Oracle Engineers Caused Days-Long Software Outage at US Hospitals
Read more of this story at Slashdot.
Duolingo Will Replace Contract Workers With AI
Read more of this story at Slashdot.
Digital Photo Frame Company Nixplay Slashes Free Cloud Storage From 10GB To 500MB
Read more of this story at Slashdot.
OpenAI Upgrades ChatGPT Search With Shopping Features
Read more of this story at Slashdot.
Soft Vine-Like Robot Helps Rescuers Find Survivors In Disaster Zones
Read more of this story at Slashdot.
Milwaukee Police Consider Trading Millions of Mugshots For Free Facial Recognition Access
Read more of this story at Slashdot.
Monero Likely Pumped 50% Due To Suspected $330 Million Bitcoin Theft
Read more of this story at Slashdot.
Neurotech Companies Are Selling Brain Data, Senators Warn
Read more of this story at Slashdot.