91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 30KB
    文件類型: .gz
    金幣: 1
    下載: 1 次
    發布日期: 2021-06-25
  • 語言: C/C++
  • 標簽: electric-fen??efence??

資源簡介

electric fence是Linux下的C語言內存越界訪問檢測工具,可檢測如下兩種情況:1、內存訪問越界 2、使用釋放后續的內存 使用方法: 1、make編譯得到libefence.a靜態庫 2、在gcc編譯時增加 -L . -lefence的選項

資源截圖

代碼片段和文件信息

/*
?*?Electric?Fence?-?Red-Zone?memory?allocator.
?*?Bruce?Perens?1988?1993
?*?
?*?This?is?a?special?version?of?malloc()?and?company?for?debugging?software
?*?that?is?suspected?of?overrunning?or?underrunning?the?boundaries?of?a
?*?malloc?buffer?or?touching?free?memory.
?*
?*?It?arranges?for?each?malloc?buffer?to?be?followed?(or?preceded)
?*?in?the?address?space?by?an?inaccessable?virtual?memory?page
?*?and?for?free?memory?to?be?inaccessable.?If?software?touches?the
?*?inaccessable?page?it?will?get?an?immediate?segmentation
?*?fault.?It?is?then?trivial?to?uncover?the?offending?code?using?a?debugger.
?*
?*?An?advantage?of?this?product?over?most?malloc?debuggers?is?that?this?one
?*?detects?reading?out?of?bounds?as?well?as?writing?and?this?one?stops?on
?*?the?exact?instruction?that?causes?the?error?rather?than?waiting?until?the
?*?next?boundary?check.
?*
?*?There?is?one?product?that?debugs?malloc?buffer?overruns
?*?better?than?Electric?Fence:?“Purify“?from?Purify?Systems?and?that‘s?only
?*?a?small?part?of?what?Purify?does.?I‘m?not?affiliated?with?Purify?I?just
?*?respect?a?job?well?done.
?*
?*?This?version?of?malloc()?should?not?be?linked?into?production?software
?*?since?it?tremendously?increases?the?time?and?memory?overhead?of?malloc().
?*?Each?malloc?buffer?will?consume?a?minimum?of?two?virtual?memory?pages
?*?this?is?16?kilobytes?on?many?systems.?On?some?systems?it?will?be?necessary
?*?to?increase?the?amount?of?swap?space?in?order?to?debug?large?programs?that
?*?perform?lots?of?allocation?because?of?the?per-buffer?overhead.
?*/
#include?“efence.h“
#include?
#include?
#include?
#include?
#include?
#ifdef?USE_SEMAPHORE
#?include?
#?include?
#endif

#ifdef malloc
#undef malloc
#endif

#ifdef calloc
#undef calloc
#endif

static?const?char version[]?=?“\n??Electric?Fence?2.2“
?“?Copyright?(C)?1987-1999?Bruce?Perens?\n“;

/*
?*?MEMORY_CREATION_SIZE?is?the?amount?of?memory?to?get?from?the?operating
?*?system?at?one?time.?We‘ll?break?that?memory?down?into?smaller?pieces?for
?*?malloc?buffers.?One?megabyte?is?probably?a?good?value.
?*/
#define MEMORY_CREATION_SIZE 1024?*?1024

/*
?*?Enum?Mode?indicates?the?status?of?a?malloc?buffer.
?*/
enum?_Mode?{
NOT_IN_USE?=?0 /*?Available?to?represent?a?malloc?buffer.?*/
FREE /*?A?free?buffer.?*/
ALLOCATED /*?A?buffer?that?is?in?use.?*/
PROTECTED /*?A?freed?buffer?that?can?not?be?allocated?again.?*/
INTERNAL_USE /*?A?buffer?used?internally?by?malloc().?*/
};
typedef?enum?_Mode Mode;

/*
?*?Struct?Slot?contains?all?of?the?information?about?a?malloc?buffer?except
?*?for?the?contents?of?its?memory.
?*/
struct?_Slot?{
void?* userAddress;
void?* internalAddress;
size_t userSize;
size_t internalSize;
Mode mode;
};
typedef?struct?_Slot Slot;

static?void?*memalign_locked(size_t?alignment?size_t?userSize);
static?void?free_locked(void?*address);

?/*
?*?EF_DISABLE_BANNER?is?a?global?variable?used?to?c

評論

共有 條評論

相關資源