|
33 | 33 | #include <string.h> |
34 | 34 | #include <math.h> |
35 | 35 |
|
36 | | -#include <nmmintrin.h> /// for crc32 intrinsic |
| 36 | +#include <nmmintrin.h> /// for crc32 intrinsic |
37 | 37 | #include <inttypes.h> |
38 | 38 | #define __STDC_FORMAT_MACROS |
39 | 39 |
|
@@ -105,22 +105,22 @@ typedef unsigned long long STACK_CANARY_TYPE; /// Type for canaries can |
105 | 105 | typedef int stack_status; /// stack status is a bitset inside an int |
106 | 106 |
|
107 | 107 | enum stack_status_enum { /// ERROR codes for stack |
108 | | - STACK_OK = 0, /// All_is_fine status |
109 | | - |
110 | | - STACK_BAD_STRUCT_PTR = 0b00001, /// Bad ptr for stack structure provided |
111 | | - STACK_BAD_DATA_PTR = 0b00010, /// Bad ptr for stack data |
112 | | - STACK_BAD_MEM_ALLOC = 0b00100, /// Error during memory (re)allocation |
113 | | - STACK_INTEGRITY_VIOLATED = 0b01000, /// Stack structure intergrity violated |
114 | | - STACK_DATA_INTEGRITY_VIOLATED = 0b10000, /// Stack data intergrity violated |
115 | | - |
116 | | - STACK_LEFT_STRUCT_CANARY_CORRUPT = 0b0001000000, /// Stack canary has been modified |
117 | | - STACK_RIGHT_STRUCT_CANARY_CORRUPT = 0b0010000000, /// could happen if big chank of data |
118 | | - STACK_LEFT_DATA_CANARY_CORRUPT = 0b0100000000, /// has been carelessly filled with data |
119 | | - STACK_RIGHT_DATA_CANARY_CORRUPT = 0b1000000000, /// or if stack data has been writen above it |
120 | | - |
121 | | - STACK_BAD_STRUCT_HASH = 0b0010000000000, /// Bad hash of all stack structure filds |
122 | | - STACK_BAD_DATA_HASH = 0b0100000000000, /// Bad hash of all the stack data |
123 | | - STACK_BAD_CAPACITY = 0b1000000000000 /// Stack capacity has been modified and/or is clearly incorrect |
| 108 | + STACK_OK = 0, /// All_is_fine status |
| 109 | + |
| 110 | + STACK_BAD_STRUCT_PTR = 1<<0, /// Bad ptr for stack structure provided |
| 111 | + STACK_BAD_DATA_PTR = 1<<1, /// Bad ptr for stack data |
| 112 | + STACK_BAD_MEM_ALLOC = 1<<2, /// Error during memory (re)allocation |
| 113 | + STACK_INTEGRITY_VIOLATED = 1<<3, /// Stack structure intergrity violated |
| 114 | + STACK_DATA_INTEGRITY_VIOLATED = 1<<4, /// Stack data intergrity violated |
| 115 | + |
| 116 | + STACK_LEFT_STRUCT_CANARY_CORRUPT = 1<<7, /// Stack canary has been modified |
| 117 | + STACK_RIGHT_STRUCT_CANARY_CORRUPT = 1<<8, /// could happen if big chank of data |
| 118 | + STACK_LEFT_DATA_CANARY_CORRUPT = 1<<9, /// has been carelessly filled with data |
| 119 | + STACK_RIGHT_DATA_CANARY_CORRUPT = 1<<10, /// or if stack data has been writen above it |
| 120 | + |
| 121 | + STACK_BAD_STRUCT_HASH = 1<<13, /// Bad hash of all stack structure filds |
| 122 | + STACK_BAD_DATA_HASH = 1<<14, /// Bad hash of all the stack data |
| 123 | + STACK_BAD_CAPACITY = 1<<15 /// Stack capacity has been modified and/or is clearly incorrect |
124 | 124 | }; |
125 | 125 |
|
126 | 126 |
|
@@ -192,9 +192,8 @@ static bool ptrValid(const void* ptr); |
192 | 192 | #endif |
193 | 193 |
|
194 | 194 |
|
195 | | -/// macro for accessing left data canary wrapper from inside of a func with defined `this_` |
| 195 | +/// macros for accessing Left and Right data canary wrapper from inside of a func with defined `this_` |
196 | 196 | #define LEFT_CANARY_WRAPPER (this_->dataWrapper) |
197 | | -/// macro for accessing right data canary wrapper from inside of a func with defined `this_` |
198 | 197 | #define RIGHT_CANARY_WRAPPER ((STACK_CANARY_TYPE*)((char*)this_->dataWrapper + STACK_CANARY_WRAPPER_LEN * sizeof(STACK_CANARY_TYPE) + this_->capacity * sizeof(STACK_TYPE))) |
199 | 198 |
|
200 | 199 |
|
@@ -378,7 +377,7 @@ static stack_status stack_push(stack *this_, STACK_TYPE item); |
378 | 377 | * @fn static stack_status stack_pop (stack *this_, STACK_TYPE item) |
379 | 378 | * @brief pops last elem from stack |
380 | 379 | * @param this_ pointer to stack |
381 | | - * @param item pointer to var to write to |
| 380 | + * @param item pointer to var to write to or NULL if value should be discarded |
382 | 381 | * @return bitset of stack status |
383 | 382 | */ |
384 | 383 | static stack_status stack_pop (stack *this_, STACK_TYPE* item); |
|
0 commit comments