Skip to contentSkip to conversation

lib/string.c: Clarify kerndoc for stpcpy()

PATCH In review Kees Cook 3 participants 4 messages Sep 6, 2020 – Sep 14, 2020

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 lib/string.c: Clarify kerndoc for stpcpy()

Fix the language around return values to indicate destination instead of source.

---
This is a fix for lib-stringc-implement-stpcpy.patch in -mm.

Andrew, please note that it would be nice to get this into -rc6 to unbreak the clang builds.

Thanks!

---
 lib/string.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
lib/string.c +6 -6
index 6bd0cf0fb009..32a56436c7eb 100644
@@ -280,12 +280,12 @@ EXPORT_SYMBOL(strscpy_pad);
  * @src: pointer to the beginning of string being copied from. Must not overlap
  *       dest.
  *
- * stpcpy differs from strcpy in a key way: the return value is the new
- * %NUL-terminated character. (for strcpy, the return value is a pointer to
- * src. This interface is considered unsafe as it doesn't perform bounds
- * checking of the inputs. As such it's not recommended for usage. Instead,
- * its definition is provided in case the compiler lowers other libcalls to
- * stpcpy.
+ * stpcpy differs from strcpy in a key way: the return value is a pointer
+ * to the new %NUL-terminated character in @dest. (For strcpy, the return
+ * value is a pointer to the start of @dest. This interface is considered
+ * unsafe as it doesn't perform bounds checking of the inputs. As such it's
+ * not recommended for usage. Instead, its definition is provided in case
+ * the compiler lowers other libcalls to stpcpy.
  */
 char *stpcpy(char *__restrict__ dest, const char *__restrict__ src);
 char *stpcpy(char *__restrict__ dest, const char *__restrict__ src)
Signature · 5 lines
2.25.1


-- 
Kees Cook
#1 lore raw
Quoted 25 lines · Kees Cook

Fix the language around return values to indicate destination instead of source.

---
This is a fix for lib-stringc-implement-stpcpy.patch in -mm.

Andrew, please note that it would be nice to get this into -rc6 to unbreak the clang builds.

Thanks!

---
 lib/string.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
lib/string.c +0 -0
index 6bd0cf0fb009..32a56436c7eb 100644
@@ -280,12 +280,12 @@ EXPORT_SYMBOL(strscpy_pad);
  * @src: pointer to the beginning of string being copied from. Must not overlap
  *       dest.

lib/string.c EXPORT_SYMBOL(strscpy_pad); · line 285

Quoted 10 lines
lib/string.c +3 -6
  *
- * stpcpy differs from strcpy in a key way: the return value is the new
- * %NUL-terminated character. (for strcpy, the return value is a pointer to
- * src. This interface is considered unsafe as it doesn't perform bounds
- * checking of the inputs. As such it's not recommended for usage. Instead,
- * its definition is provided in case the compiler lowers other libcalls to
- * stpcpy.
+ * stpcpy differs from strcpy in a key way: the return value is a pointer
+ * to the new %NUL-terminated character in @dest. (For strcpy, the return
+ * value is a pointer to the start of @dest. This interface is considered

^ need closing parenthesis

Thanks.

author
#2 lore raw
Quoted 38 lines · Arvind Sankar
Quoted 25 lines · Kees Cook

Fix the language around return values to indicate destination instead of source.

---
This is a fix for lib-stringc-implement-stpcpy.patch in -mm.

Andrew, please note that it would be nice to get this into -rc6 to unbreak the clang builds.

Thanks!

---
 lib/string.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
lib/string.c +0 -0
index 6bd0cf0fb009..32a56436c7eb 100644
@@ -280,12 +280,12 @@ EXPORT_SYMBOL(strscpy_pad);
  * @src: pointer to the beginning of string being copied from. Must not overlap
  *       dest.

lib/string.c EXPORT_SYMBOL(strscpy_pad); · line 285

Quoted 10 lines
lib/string.c +3 -6
  *
- * stpcpy differs from strcpy in a key way: the return value is the new
- * %NUL-terminated character. (for strcpy, the return value is a pointer to
- * src. This interface is considered unsafe as it doesn't perform bounds
- * checking of the inputs. As such it's not recommended for usage. Instead,
- * its definition is provided in case the compiler lowers other libcalls to
- * stpcpy.
+ * stpcpy differs from strcpy in a key way: the return value is a pointer
+ * to the new %NUL-terminated character in @dest. (For strcpy, the return
+ * value is a pointer to the start of @dest. This interface is considered

^ need closing parenthesis

Quoted 1 line

Thanks.

*face in hands* Yup. Andrew, do you want to poke that yourself or should I send a fix-fix? :)

Signature · 1 line
Kees Cook
maintainer
#3 lore raw
Quoted 39 lines · On Sun, 6 Sep 2020 13:26:32 -0700 Kees Cook <[email protected]> wrote:
Quoted 38 lines · Arvind Sankar
Quoted 25 lines · Kees Cook

Fix the language around return values to indicate destination instead of source.

---
This is a fix for lib-stringc-implement-stpcpy.patch in -mm.

Andrew, please note that it would be nice to get this into -rc6 to unbreak the clang builds.

Thanks!

---
 lib/string.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
lib/string.c +0 -0
index 6bd0cf0fb009..32a56436c7eb 100644
@@ -280,12 +280,12 @@ EXPORT_SYMBOL(strscpy_pad);
  * @src: pointer to the beginning of string being copied from. Must not overlap
  *       dest.

lib/string.c EXPORT_SYMBOL(strscpy_pad); · line 285

Quoted 10 lines
lib/string.c +3 -6
  *
- * stpcpy differs from strcpy in a key way: the return value is the new
- * %NUL-terminated character. (for strcpy, the return value is a pointer to
- * src. This interface is considered unsafe as it doesn't perform bounds
- * checking of the inputs. As such it's not recommended for usage. Instead,
- * its definition is provided in case the compiler lowers other libcalls to
- * stpcpy.
+ * stpcpy differs from strcpy in a key way: the return value is a pointer
+ * to the new %NUL-terminated character in @dest. (For strcpy, the return
+ * value is a pointer to the start of @dest. This interface is considered

^ need closing parenthesis

Quoted 4 lines
Quoted 1 line

Thanks.

*face in hands* Yup. Andrew, do you want to poke that yourself or should I send a fix-fix? :)

I haven't got onto the stpcpy() base patch yet, so a full resend of a v4 would be nice please.