Skip to content

Commit 014a534

Browse files
committed
librasan: Remove optimized strlen
1 parent 773c106 commit 014a534

File tree

1 file changed

+3
-15
lines changed
  • libafl_qemu/librasan/asan/cc/src

1 file changed

+3
-15
lines changed

libafl_qemu/librasan/asan/cc/src/strlen.c

+3-15
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,16 @@
2525
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2626
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2727
*
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.
2931
*/
3032

3133
#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)
3934

4035
size_t strlen(const char *s)
4136
{
4237
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
5038
for (; *s; s++);
5139
return s-a;
5240
}

0 commit comments

Comments
 (0)