Date: Thu, 16 Feb 2023 11:56:42 GMT From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= <dumbbell@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 9752a6c97383 - stable/13 - linuxkpi: Add `strscpy_pad()` to <linux/string.h> Message-ID: <202302161156.31GBugxw056579@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=9752a6c97383d2b65a1e9f363e9ea6a7308c60dd commit 9752a6c97383d2b65a1e9f363e9ea6a7308c60dd Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> AuthorDate: 2023-02-14 23:46:13 +0000 Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> CommitDate: 2023-02-16 11:55:22 +0000 linuxkpi: Add `strscpy_pad()` to <linux/string.h> It's the same as `strscpy()` except that it fills the rest of the destination buffer with zeroes if the source buffer is shorter. Reviewed by: manu Approved by: manu (cherry picked from commit b1a9e570fe2da0a43c41327d7ce21b27bf8257b8) --- sys/compat/linuxkpi/common/include/linux/string.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h index 65422cac629c..20c3729aaf12 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -207,6 +207,15 @@ strscpy(char* dst, const char* src, size_t len) return (-E2BIG); } +static inline ssize_t +strscpy_pad(char* dst, const char* src, size_t len) +{ + + bzero(dst, len); + + return (strscpy(dst, src, len)); +} + static inline void * memset32(uint32_t *b, uint32_t c, size_t len) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302161156.31GBugxw056579>