The software for cars tends to be far and beyond the complexity than credit is given for it - It's been researched that high-end cars have 100 million lines of code and beyond (not sure what "high-end" is defined as but I'm guessing it means more MB/BMW than Dacia) - Granted this includes everything beyond the non-critical systems, including the entertainment system, but still, it does highlight the complexity involved. See graph below.
If an industry-average consumer-grade vehicle hits 15-50 bugs per 1,000 lines of code, then that is 1,500,000 to 5,000,000 bugs of various degrees across your car electronics. Scary biscuits, eh? Let's just pretend they achieved a clean-room level of bugs and only hit 3 defects per 1,000 lines, then that's still 300,000 bugs.
On the upside, most of these will probably be "dark corners" and weird edge cases that get hit with an very small probability - The most crucial systems are likely VERY well tested with many many layers of fail-safe and self-check diagnostics (think "limp mode" and you're not far off it).
But yes, the more lines of code, the more likely bugs are present - Bugs equal attack vectors that hackers, ethical or otherwise, can exploit. Although given the likelihood, you're more likely to experience glitches and gremlins than have someone maliciously disabling (or controlling) your car, for now anyway.
Still, the next time you have a gremlin in your car ... Spare a thought for the programmers and testers of those systems. They're probably getting it in the neck as you read this for high severity bugs that are deliciously difficult to find and fix.
Que not-so-random and illuminating graph:
Source:
Million Lines of Code | Information Is Beautiful