File tree 1 file changed +3
-15
lines changed
libafl_qemu/librasan/asan/cc/src
1 file changed +3
-15
lines changed Original file line number Diff line number Diff line change 25
25
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
26
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
27
*
28
- * Parentheses have been added to HASZERO macro to fix compiler warning.
28
+ * The optimized version that checks for null bytes per word has been removed,
29
+ * since it can overread the buffer if the null terminator is not the last byte
30
+ * of the buffer.
29
31
*/
30
32
31
33
#include <string.h>
32
- #include <stdint.h>
33
- #include <limits.h>
34
-
35
- #define ALIGN (sizeof(size_t))
36
- #define ONES ((size_t)-1/UCHAR_MAX)
37
- #define HIGHS (ONES * (UCHAR_MAX/2+1))
38
- #define HASZERO (x ) (((x)-ONES) & ~(x) & HIGHS)
39
34
40
35
size_t strlen (const char * s )
41
36
{
42
37
const char * a = s ;
43
- #ifdef __GNUC__
44
- typedef size_t __attribute__ ( (__may_alias__ )) word ;
45
- const word * w ;
46
- for (; (uintptr_t )s % ALIGN ; s ++ ) if (!* s ) return s - a ;
47
- for (w = (const void * )s ; !HASZERO (* w ); w ++ );
48
- s = (const void * )w ;
49
- #endif
50
38
for (; * s ; s ++ );
51
39
return s - a ;
52
40
}
You can’t perform that action at this time.
0 commit comments