Anti-DDoS program module indirectly transmits STL instance objects through struct

Source: Internet
Author: User

Anti-DDoS program module indirectly transmits STL instance objects through struct

We often pass parameters to functions through struct. In principle, the struct should not contain non-pod members.

[Reference]
========================================================== ==========================================
Pod, short for plain old data, a common old data structure (POD) is a data structure. It is used only as the field value of passive favorites, and does not use the packet or otherobject-oriented feature. (A plain old data structure (POD) is a data structurethat is represented only as passive collections of field values, without using encapsulationor otherobject-orientedfeatures .)
========================================================== ==========================================

For more information, see the following post:

Struct definition should not contain non-built-in type members
Http://www.pc.nd/index.php? Doc-view-10894 (company intranet, cannot access, please forgive me)

Unfortunately, we often include non-pod members in the struct. Of course, aside from the issues mentioned in the above post (problems caused by memset (& info, 0, sizeof (Info);), there seems to be no worries, this applies even if the STL instance object is included. Indeed, in the same program module, such problems can be avoided with a little attention.

However, such behavior is highly risky when data is transmitted between multiple modules.

First of all, it is very dangerous to pass STL instance objects between modules, and the resulting crash is difficult to troubleshoot. For related problems, please refer to the following two posts:

DLL Import and Export STL class objects cause a crash
Http://www.pc.nd/index.php? Doc-view-12643 (company intranet, cannot access, please forgive me)

Cross-dll stl exception
Http://www.pc.nd/index.php? Doc-view-12743 (company intranet, cannot access, please forgive me)

In addition, if the STL instance object is indirectly transmitted to functions in other modules through the struct, the danger is hidden and becomes a difficult trap to discover. For example, a struct directly contains members of an STL instance object. In addition, a struct contains a custom type object, which directly or indirectly contains members of an STL instance object.

When other modules access the elements in this STL instance object, the program will crash when mines break out!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.