Discussion
Casting a byte buffer to a structure pointer to parse a network packet is unsafe chiefly because of
Answer: C
Correct answer: alignment and padding assumptions
The compiler inserts padding to align members, and the layout it chooses need not match the packing of the network protocol. Worse, a byte buffer may not be aligned as the structure requires, and an unaligned access faults on some processors. Parsing field by field, or a packed structure with the endianness handled explicitly, is the safe route.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development