Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba13b75c authored by Vikram Mulukutla's avatar Vikram Mulukutla
Browse files

Revert "replace incorrect strscpy use in FORTIFY_SOURCE"



This reverts commit 4c5c1c70.

The author attribution is incorrect and will be corrected soon.

Change-Id: I97767788e2ca5a827ffd2f4730877f211382826e
Signed-off-by: default avatarVikram Mulukutla <markivx@codeaurora.org>
parent 14fd7a29
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -178,6 +178,17 @@ void __read_overflow2(void) __compiletime_error("detected read beyond size of ob
void __write_overflow(void) __compiletime_error("detected write beyond size of object passed as 1st parameter");

#if !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE)
__FORTIFY_INLINE char *strcpy(char *p, const char *q)
{
	size_t p_size = __builtin_object_size(p, 0);
	size_t q_size = __builtin_object_size(q, 0);
	if (p_size == (size_t)-1 && q_size == (size_t)-1)
		return __builtin_strcpy(p, q);
	if (strscpy(p, q, p_size < q_size ? p_size : q_size) < 0)
		fortify_panic(__func__);
	return p;
}

__FORTIFY_INLINE char *strncpy(char *p, const char *q, __kernel_size_t size)
{
	size_t p_size = __builtin_object_size(p, 0);
@@ -356,18 +367,6 @@ __FORTIFY_INLINE void *kmemdup(const void *p, size_t size, gfp_t gfp)
		fortify_panic(__func__);
	return __real_kmemdup(p, size, gfp);
}

/* defined after fortified strlen and memcpy to reuse them */
__FORTIFY_INLINE char *strcpy(char *p, const char *q)
{
	size_t p_size = __builtin_object_size(p, 0);
	size_t q_size = __builtin_object_size(q, 0);
	if (p_size == (size_t)-1 && q_size == (size_t)-1)
		return __builtin_strcpy(p, q);
	memcpy(p, q, strlen(q) + 1);
	return p;
}

#endif

#endif /* _LINUX_STRING_H_ */