New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

GAQM CPEH-001 Exam - Topic 4 Question 114 Discussion

Actual exam question for GAQM's CPEH-001 exam
Question #: 114
Topic #: 4
[All CPEH-001 Questions]

Buffer X in an Accounting application module for Brownies Inc. can contain 200 characters. The programmer makes an assumption that 200 characters are more than enough. Because there were no proper boundary checks being conducted, Bob decided to insert 400 characters into the 200-character buffer. (Overflows the buffer). Below is the code snippet:

How can you protect/fix the problem of your application as shown above?

Show Suggested Answer Hide Answer
Suggested Answer: A, D

Contribute your Thoughts:

0/2000 characters
Lavonne
2 months ago
Option D seems like the best fix to me.
upvoted 0 times
...
Karol
2 months ago
I totally agree, proper boundary checks are a must!
upvoted 0 times
...
Queen
3 months ago
Isn't it surprising that they assumed 200 characters would always be enough?
upvoted 0 times
...
Troy
3 months ago
Wait, how did they not see this coming?
upvoted 0 times
...
Maile
3 months ago
Buffer overflow is a common issue in programming.
upvoted 0 times
...
Anabel
3 months ago
I recall that we should definitely have a condition to prevent writing more than 200 characters, so I lean towards option D as the best choice.
upvoted 0 times
...
Marylyn
4 months ago
I’m a bit confused about the counter starting at 0. Does that mean we should stop at 200 or 199? I need to think this through more.
upvoted 0 times
...
Narcisa
4 months ago
I think we practiced something similar where we had to stop writing when we reached the buffer limit, so I feel like option D makes sense to me.
upvoted 0 times
...
Nakisha
4 months ago
I remember we discussed boundary checks in class, but I'm not sure if it's option A or D that correctly addresses the overflow issue.
upvoted 0 times
...
Corazon
4 months ago
Okay, I think I've got it. The solution is to add a check to ensure that the number of characters being written to the buffer does not exceed the buffer size. Option D looks like the best choice here.
upvoted 0 times
...
Amie
4 months ago
Ah, I see the problem now. The programmer made the assumption that 200 characters would be enough, but then allowed 400 characters to be written to the buffer. The fix is simple - we just need to add a check to make sure the buffer size is not exceeded.
upvoted 0 times
...
Mitsue
5 months ago
I'm a bit confused by the code snippet. It's not clear to me exactly where the buffer overflow is happening. I'll need to carefully read through the code and think through the logic to figure out the best way to fix this.
upvoted 0 times
...
Lili
5 months ago
This looks like a classic buffer overflow issue. I think the key is to properly check the buffer size and not allow more data to be written than the buffer can hold.
upvoted 0 times
...
Gail
6 months ago
But D doesn't take into account the buffer size, so I still think C is the better choice.
upvoted 0 times
...
Enola
6 months ago
I'm not sure, I think D could also be a valid solution.
upvoted 0 times
...
Bette
6 months ago
I agree with Gail, C seems like the best option.
upvoted 0 times
...
Rochell
6 months ago
Hmm, let's see... I'd say option D is the way to go. Checking the buffer size and stopping the write when it's full is the safest approach. Can't have Bob's shenanigans messing up the app, now can we?
upvoted 0 times
...
Thurman
6 months ago
Option D is the clear winner here. Limiting the write to the buffer size is the best way to prevent this kind of buffer overflow problem. Nice try, Bob, but we can't let you break the system like that!
upvoted 0 times
Rasheeda
5 months ago
I agree, option D is the best choice to prevent buffer overflow.
upvoted 0 times
...
...
Gail
7 months ago
I think the correct answer is C.
upvoted 0 times
...
Louis
7 months ago
Haha, good one Bob! Trying to overflow the buffer. But seriously, option D is the way to go. Gotta keep that buffer in check, you know?
upvoted 0 times
Jeff
5 months ago
User 3: User 3: Buffer overflow can cause serious issues. Option D is the best choice.
upvoted 0 times
...
Bobbye
5 months ago
User 2: User 2: Yeah, that's a classic mistake. Option D is definitely the fix.
upvoted 0 times
...
Martina
6 months ago
User 1: Haha, Bob, you really tried to overflow the buffer?
upvoted 0 times
...
...
Ettie
8 months ago
Definitely go with option D. Adding a separate statement to check if the buffer has reached its capacity is the most straightforward way to fix this issue.
upvoted 0 times
Kerry
6 months ago
Absolutely, option D is the way to go to protect the application from buffer overflow.
upvoted 0 times
...
Horace
7 months ago
Yes, adding a separate statement to check the buffer capacity is crucial in avoiding such issues.
upvoted 0 times
...
Ona
7 months ago
I agree, option D is the best solution to prevent buffer overflow.
upvoted 0 times
...
...

Save Cancel