Error C6385 In C++ (AES) - Programming - Linus Tech Tips
- Recent Topics
- Home
- Software
- Programming
- Error C6385 in C++ (AES)
- c++
- error c6385
- aes
-
-
Lennart van de Merwe
- Member
- 254
- 3
-
-
AbydosOne
- Member
- Sony Fanboy
- 4.4k
- 305
- Lennart van de Merwe
-
1 -
-
Lennart van de Merwe
- Member
- 254
- 3
- Author
-
-
AbydosOne
- Member
- Sony Fanboy
- 4.4k
- 305
-
-
Lennart van de Merwe
- Member
- 254
- 3
- Author
-
-
wanderingfool2
- Member
- 3.9k
- 27
- AbydosOne
-
1 -
-
Lennart van de Merwe
- Member
- 254
- 3
- Author
-
-
wanderingfool2
- Member
- 3.9k
- 27
-
-
-
-
Featured Topics
-
Credential Stuffing Attack Spotty · Yesterday at 08:26 AM
4 -
I Love WU - 2026 HoldSquat · January 8
263
-
-
Topics
-
Need mouse switch buying help ChristianHM · 35 minutes ago Posted in Peripherals
0 -
How to manage dependancies [arch] apoyusiken · 45 minutes ago Posted in Linux, macOS and Everything Not-Windows
2 -
Is the Vivobook Go 15 OLED (E1504F) a good laptop for school or is it overkill? ferbert72. · 2 hours ago Posted in Laptops and Pre-Built Systems
3 -
Low power GPU for linux with 3xDisplayPort for KVM-Switch
Eardy · 2 hours ago Posted in Graphics Cards
2 -
Asus Prime Z270A i7 7700K fails to boot
SmookinJoe · 5 hours ago Posted in Troubleshooting
1 -
Looking for gaming headset with excellent voice isolation NorwegianWoodBadger · 6 hours ago Posted in Audio
5 -
XMP Boot issue (help!)
GeneDrozd · 12 hours ago Posted in Troubleshooting
11 -
steamos gaming mode macro apoyusiken · 13 hours ago Posted in Linux, macOS and Everything Not-Windows
3 -
Moving from macOS to Windows wonderland-1989 · 14 hours ago Posted in Windows
5 -
BOINC Crunchathon 2026 (March 9th - 30th) TheLANguy · 15 hours ago Posted in Folding@home, Boinc, and Coin Mining
14
-
- Join our Discord server Get LTT merch Support us on Floatplane Support the forum
- play_circle_filled
Latest From Linus Tech Tips:
Are these a scam?
- Watch Now
- More Videos
- Discuss
- play_circle_filled
Latest From ShortCircuit:
the BEST Webcam on the market right now
- Watch Now
- More Videos
- play_circle_filled
Latest From TechLinked:
Discord is Scanning our faces now
- Watch Now
- More Videos
- play_circle_filled
Latest From GameLinked:
Valve...Don't Do This
- Watch Now
- More Videos
- Recent Topics
- Home
- Software
- Programming
- Error C6385 in C++ (AES)
- Sign Up
- Existing user? Sign In
- Forums
- Community Standards
- All Activity
-
My Activity Streams
- Back
- Status Updates
- Recent Topics
- Blogs
- Gallery
- Events
- Downloads
- Online Users
- Staff
- Forum Subscriptions
Hi guys this is Austin, I'm having a problem with my C++ project for school (it's making AES, if you're wondering). I'm a massive noob when it comes to coding, let alone C languages, so please have mercy on my soul. The problem I'm having is in the second to last line: "... else paddedMessage[x] = decryptedmessage[x];" The warning Visual gives me is coded C6385. Of course I've looked this up and I understand what the problem might be, but I can't seem to figure out the cause of it. I suspect it's something to do "decryptedmessage", but I'm not sure.The code listed above isn't the entire code (that's something like 600 lines: too much for this post I suppose, but if you need it, just ask), I've chosen to take the code from the 'birth' of decryptedmessage until the error. If you need more, once again, just ask. I'm sorry for my awful description of the problem and I know I'm a horrible noob. Please help me out, it would mean a lot. Thanks in advance.
Link to comment
https://linustechtips.com/topic/1190652-error-c6385-in-c-aes/Share on other sites
More sharing options...Link to post
Share on other sites
More sharing options...9 minutes ago, Lennart van de Merwe said:coded C6385
See here.
Basically, it's just warning you there's a chance that 'x' might be a larger value than the declared length of 'decryptedMessage'. Check that x < decryptedMessageLength in your for loop.
Main System (Byarlant): Ryzen 7 5800X | Asus B550-Creator ProArt | EK 240mm Basic AIO | 32GB G.Skill DDR4 3600MT/s CL16 | XFX Speedster SWFT 210 RX 6600 | Samsung 990 PRO 2TB / Samsung 990 EVO Plus 4TB | Corsair RM750X | Mellanox ConnectX-3 10G NIC | StarTech 4× USB 3.0 Card | Hyte Y60 Case | Dell U3415W Monitor | Keychron K12 Blue (RGB backlight)
Laptop (Narrative): Lenovo Flex 5 81X20005US | Ryzen 5 4500U | 16GB DDR4 3200MT/s (soldered) | Vega II 384SP Graphics | SKHynix P31 1TB NVMe SSD | Intel AX200 Wifi | Asus 2.5G USB NIC | Asus ProArt PA278QV | Keychron K4 Brown (white backlight)
Proxmox Server (Veda): Ryzen 7 3800XT | ASRock Rack X470D4U | Corsair H80i v2 | 128GB Micron DDR4 ECC 3200MT/s | 2× Samsung PM963a 960GB SSD / 4× WD 10TB / 4× Seagate 14TB Exos / 4× Micron MX500 2TB / 8× WD 12TB (custom external SAS enclosure) | Seasonic Prime Fanless 500W | Intel X550-T2 10G NIC | LSI 9300-8i HBA | Adaptec 82885T SAS Expander | Fractal Design Node 804 Case
Proxmox Server (La Vie en Rose): GMKtec Mini PC | Ryzen 7 5700U | 32GB Lexar DDR4 (SODIMM) | Vega II 512SP Graphics | Lexar 1TB 610 Pro SSD | 2× Realtek 8125 2.5G NICs
Media Center/Video Capture (Jesta Cannon): Ryzen 5 1600X | ASRock B450M Pro4 R2.0 | Noctua NH-L12S | 16GB Crucial DDR4 3200MT/s | EVGA GTX750Ti SC | UMIS NVMe SSD 256GB / TEAMGROUP MS30 1TB | Corsair CX450M | Viewcast Osprey 260e Video Capture | TrendNet (AQC107) 10G NIC | LG UH12NS30 BD-ROM | Silverstone Sugo SG-11 Case | Sony XR65A80K
Workbench (Doven Wolf): Lenovo m715q | Ryzen Pro 3 2200GE | 16GB Crucial DDR4 3200MT/s (SODIMM) | Vega 8 Graphics | SKHynix (OEM) 256GB NVMe SSD | uni 2.5G USB NIC | HDMI add-in module
Network:
Spoiler ┌─────────────── Office/Rack ───────────────────────────────────────────────────────┐ Google Fiber Webpass ── Cloud Gateway Max ═╦════ Flex 2.5-8 ═╦════ Flex XG ═╦═ Veda La Vie en Rose ═╣ La Vie en Rose ═╬═ Doven Wolf ╠═ Veda-NAS Veda ─╜ Narrative ═╝ ╟─ Switch 8-60W ─┬─ Veda ╔═══════════════════════════════════════════════════════════════════════════╝ └─ Veda (IPMI) ║ ┌ Closet ┐ ┌───────── Bedroom ─────────┐ ╚════ Flex XG ═╦╤═══ Flex XG ═╤╦═ Byarlant (PoE) ║│ │╠═ Narrative Kitchen Jack ══╣└─ Dual PoE ┐ │╚═ Jesta Cannon* (Testing) ║┌─ Injector ┘ └── Work Laptop Bedroom ══╝│ Jack #2 │ ┌──────── Media Center ───────────────────────────┐ └──────── Switch 8 ────────────┬─ nanoHD Access Point (PoE) Notes: ├─ Sony PlayStation 4 ─── is Gigabit / ═══ is Multi-Gigabit ├─ Pioneer VSX-S520 * = cable passed from Bedroom to Media Center └─ Sony XR65A80K (Google TV)Link to comment
https://linustechtips.com/topic/1190652-error-c6385-in-c-aes/#findComment-13573568Share on other sites
More sharing options...Link to post
Share on other sites
More sharing options...14 minutes ago, AbydosOne said:See here.
Basically, it's just warning you there's a chance that 'x' might be a larger value than the declared length of 'decryptedMessage'. Check that x < decryptedMessageLength in your for loop.
I'm sorry, but what do you mean by that? I'm a noob remember X<
Link to comment
https://linustechtips.com/topic/1190652-error-c6385-in-c-aes/#findComment-13573647Share on other sites
More sharing options...Link to post
Share on other sites
More sharing options...59 minutes ago, Lennart van de Merwe said:I'm sorry, but what do you mean by that? I'm a noob remember X<
Basically, if you have something with 10 slots, and you ask it for whatever is in slot 11, the thing isn't going to know how to respond, and so it might throw an error, or crash, or give you what would be in slot 11 if it existed (this is usually the nastiest outcome for various reasons). Point is, there a chance you might ask the array for something in a position that doesn't exist, and so you need to ensure that your value of 'x' doesn't tell the arrays 'decryptedmessage' or 'paddedMessage' (in that line) to pick from a slot beyond what they have, by making sure that 'x' is always smaller than the length of either array.
Main System (Byarlant): Ryzen 7 5800X | Asus B550-Creator ProArt | EK 240mm Basic AIO | 32GB G.Skill DDR4 3600MT/s CL16 | XFX Speedster SWFT 210 RX 6600 | Samsung 990 PRO 2TB / Samsung 990 EVO Plus 4TB | Corsair RM750X | Mellanox ConnectX-3 10G NIC | StarTech 4× USB 3.0 Card | Hyte Y60 Case | Dell U3415W Monitor | Keychron K12 Blue (RGB backlight)
Laptop (Narrative): Lenovo Flex 5 81X20005US | Ryzen 5 4500U | 16GB DDR4 3200MT/s (soldered) | Vega II 384SP Graphics | SKHynix P31 1TB NVMe SSD | Intel AX200 Wifi | Asus 2.5G USB NIC | Asus ProArt PA278QV | Keychron K4 Brown (white backlight)
Proxmox Server (Veda): Ryzen 7 3800XT | ASRock Rack X470D4U | Corsair H80i v2 | 128GB Micron DDR4 ECC 3200MT/s | 2× Samsung PM963a 960GB SSD / 4× WD 10TB / 4× Seagate 14TB Exos / 4× Micron MX500 2TB / 8× WD 12TB (custom external SAS enclosure) | Seasonic Prime Fanless 500W | Intel X550-T2 10G NIC | LSI 9300-8i HBA | Adaptec 82885T SAS Expander | Fractal Design Node 804 Case
Proxmox Server (La Vie en Rose): GMKtec Mini PC | Ryzen 7 5700U | 32GB Lexar DDR4 (SODIMM) | Vega II 512SP Graphics | Lexar 1TB 610 Pro SSD | 2× Realtek 8125 2.5G NICs
Media Center/Video Capture (Jesta Cannon): Ryzen 5 1600X | ASRock B450M Pro4 R2.0 | Noctua NH-L12S | 16GB Crucial DDR4 3200MT/s | EVGA GTX750Ti SC | UMIS NVMe SSD 256GB / TEAMGROUP MS30 1TB | Corsair CX450M | Viewcast Osprey 260e Video Capture | TrendNet (AQC107) 10G NIC | LG UH12NS30 BD-ROM | Silverstone Sugo SG-11 Case | Sony XR65A80K
Workbench (Doven Wolf): Lenovo m715q | Ryzen Pro 3 2200GE | 16GB Crucial DDR4 3200MT/s (SODIMM) | Vega 8 Graphics | SKHynix (OEM) 256GB NVMe SSD | uni 2.5G USB NIC | HDMI add-in module
Network:
Spoiler ┌─────────────── Office/Rack ───────────────────────────────────────────────────────┐ Google Fiber Webpass ── Cloud Gateway Max ═╦════ Flex 2.5-8 ═╦════ Flex XG ═╦═ Veda La Vie en Rose ═╣ La Vie en Rose ═╬═ Doven Wolf ╠═ Veda-NAS Veda ─╜ Narrative ═╝ ╟─ Switch 8-60W ─┬─ Veda ╔═══════════════════════════════════════════════════════════════════════════╝ └─ Veda (IPMI) ║ ┌ Closet ┐ ┌───────── Bedroom ─────────┐ ╚════ Flex XG ═╦╤═══ Flex XG ═╤╦═ Byarlant (PoE) ║│ │╠═ Narrative Kitchen Jack ══╣└─ Dual PoE ┐ │╚═ Jesta Cannon* (Testing) ║┌─ Injector ┘ └── Work Laptop Bedroom ══╝│ Jack #2 │ ┌──────── Media Center ───────────────────────────┐ └──────── Switch 8 ────────────┬─ nanoHD Access Point (PoE) Notes: ├─ Sony PlayStation 4 ─── is Gigabit / ═══ is Multi-Gigabit ├─ Pioneer VSX-S520 * = cable passed from Bedroom to Media Center └─ Sony XR65A80K (Google TV)Link to comment
https://linustechtips.com/topic/1190652-error-c6385-in-c-aes/#findComment-13573873Share on other sites
More sharing options...Link to post
Share on other sites
More sharing options...2 minutes ago, AbydosOne said:Basically, if you have something with 10 slots, and you ask it for whatever is in slot 11, the thing isn't going to know how to respond, and so it might throw an error, or crash, or give you what would be in slot 11 if it existed (this is usually the nastiest outcome for various reasons). Point is, there a chance you might ask the array for something in a position that doesn't exist, and so you need to ensure that your value of 'x' doesn't tell the arrays 'decryptedmessage' or 'paddedMessage' (in that line) to pick from a slot beyond what they have, by making sure that 'x' is always smaller than the length of either array.
Yes, but that int is determined by taking the length of the decryptedmessage, which then also defines the length of the paddedmessage. Could it be something to do with:
int originalLen = strlen((const char*)decryptedmessage); int lenOfPaddedMessage = originalLen;Link to comment
https://linustechtips.com/topic/1190652-error-c6385-in-c-aes/#findComment-13573885Share on other sites
More sharing options...Link to post
Share on other sites
More sharing options...5 minutes ago, Lennart van de Merwe said:Yes, but that int is determined by taking the length of the decryptedmessage, which then also defines the length of the paddedmessage. Could it be something to do with:
int originalLen = strlen((const char*)decryptedmessage); int lenOfPaddedMessage = originalLen;
It's a compiler warning, which means that it doesn't always do the most indepth analysis of what the upper bound may be. It is giving that warning because it just detected that the number might be larger than the original (in this case it is sort of a guideline to look into to make sure it won't).
As a note though, strlen is null terminated; so yes originalLen could be greater than the defined length and you could be reading the memory that comes after the decryptedmessage.
int main() { char[2] a; a[0] = 'a'; a[1] = 'b'; int len = strlen(a); //Len is not well defined. In theory you might think it is 2, but in practice it could be anything //Since it will depend what is stored in the memory location a[2] (sometimes it might be 0, so you might get the right answer) //but it isn't guarenteed return 0; }
All you could use something like as follows to catch it properly
if(lenOfPaddedMessage > LenOfPaddedMessage) lenOfPaddedMessage = LenOfPaddedMessage;
*So now this is just my opinion, but it I always try keeping variable names distinct from each other. Yes, l vs L makes it a different variable but to me it just makes things confusing when they are used together (having to remember which is which as I don't usually process the capitals in my head)
3735928559 - Beware of the dead beef
Link to comment
https://linustechtips.com/topic/1190652-error-c6385-in-c-aes/#findComment-13573993Share on other sites
More sharing options...Link to post
Share on other sites
More sharing options...10 minutes ago, wanderingfool2 said:It's a compiler warning, which means that it doesn't always do the most indepth analysis of what the upper bound may be. It is giving that warning because it just detected that the number might be larger than the original (in this case it is sort of a guideline to look into to make sure it won't).
As a note though, strlen is null terminated; so yes originalLen could be greater than the defined length and you could be reading the memory that comes after the decryptedmessage.
int main() { char[2] a; a[0] = 'a'; a[1] = 'b'; int len = strlen(a); //Len is not well defined. In theory you might think it is 2, but in practice it could be anything //Since it will depend what is stored in the memory location a[2] (sometimes it might be 0, so you might get the right answer) //but it isn't guarenteed return 0; }
All you could use something like as follows to catch it properly
if(lenOfPaddedMessage > LenOfPaddedMessage) lenOfPaddedMessage = LenOfPaddedMessage;
*So now this is just my opinion, but it I always try keeping variable names distinct from each other. Yes, l vs L makes it a different variable but to me it just makes things confusing when they are used together (having to remember which is which as I don't usually process the capitals in my head)
Thanks a lot for the input and clear explanation. Unfortunately it only makes it worse when it comes to the output of the code, so I'm leaving the bug as it is, especially since I have to start handing in my assignment.
Link to comment
https://linustechtips.com/topic/1190652-error-c6385-in-c-aes/#findComment-13574055Share on other sites
More sharing options...Link to post
Share on other sites
More sharing options...17 minutes ago, Lennart van de Merwe said:Thanks a lot for the input and clear explanation. Unfortunately it only makes it worse when it comes to the output of the code, so I'm leaving the bug as it is, especially since I have to start handing in my assignment.
Okay, so I actually read your code...yea, you would actually want to apply the fix to originalLen...or if it allows it strnlen...and cap it there
3735928559 - Beware of the dead beef
Link to comment
https://linustechtips.com/topic/1190652-error-c6385-in-c-aes/#findComment-13574175Share on other sites
More sharing options...Link to post
Share on other sites
More sharing options...Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now Share https://linustechtips.com/topic/1190652-error-c6385-in-c-aes/ More sharing options... Followers 2 Go to topic listing ProgrammingTừ khóa » C C6385
-
C6385 - Microsoft Docs
-
Warning C6385 In Visual Studio - C++ - Stack Overflow
-
How Do I Get Rid Of This Warning C6385 Reading Invalid Data
-
C6385 False Positive - Visual Studio Feedback
-
False Positive Of C6385 When Accessing Arrays Of Class Types
-
C6385 Reading Invalid Data From 'array': The Readable Size Is '4 ...
-
Warning C6385: Am I Being Dumb? : R/VisualStudio - Reddit
-
Visual Studio C6385 Warning C++ - Anycodings
-
[Solved]-How Do I Fix Compiler Warnings C6386 And C6385?-C++
-
Daniel Hlubinka | Publons
-
Resolving Potential False Negative C6385 Error In C++ - Dev Solutions
-
Sammy C (c6385) - Profile - Pinterest
-
Sarif-sdk/C6385output1.xml At Main - GitHub
-
If Statement Doesn't Work Correctly - C++ Forum