Tobin C. Harding
651b709117
lib/string: Add strscpy_pad() function
...
[ Upstream commit 458a3bf82df4fe1f951d0f52b1e0c1e9d5a88a3b ]
We have a function to copy strings safely and we have a function to copy
strings and zero the tail of the destination (if source string is
shorter than destination buffer) but we do not have a function to do
both at once. This means developers must write this themselves if they
desire this functionality. This is a chore, and also leaves us open to
off by one errors unnecessarily.
Add a function that calls strscpy() then memset()s the tail to zero if
the source string is shorter than the destination buffer.
Acked-by: Kees Cook <keescook@chromium.org >
Signed-off-by: Tobin C. Harding <tobin@kernel.org >
Signed-off-by: Shuah Khan <shuah@kernel.org >
Signed-off-by: Sasha Levin <sashal@kernel.org >
2021-02-23 13:58:12 +01:00
..
2015-10-14 22:23:17 +08:00
2020-11-10 10:22:19 +01:00
2016-05-04 14:48:41 -07:00
2020-06-20 10:23:20 +02:00
2019-12-21 10:35:22 +01:00
2019-08-04 09:34:48 +02:00
2015-09-10 13:29:01 -07:00
2020-06-29 20:07:53 -04:00
2017-12-16 10:33:48 +01:00
2019-03-23 08:44:33 +01:00
2018-07-17 11:31:44 +02:00
2015-07-27 14:06:24 +02:00
2020-01-29 10:21:52 +01:00
2014-12-22 16:43:06 +00:00
2019-04-27 09:33:51 +02:00
2015-11-23 09:44:58 +01:00
2015-05-28 11:31:52 +09:30
2015-01-29 11:57:38 -08:00
2017-06-29 12:48:51 +02:00
2015-05-27 15:22:15 +02:00
2020-05-27 16:40:27 +02:00
2020-10-29 09:03:06 +01:00
2015-05-26 15:26:43 +02:00
2015-05-30 22:42:24 -07:00
2015-06-11 15:08:32 +02:00
2018-11-21 09:27:31 +01:00
2018-12-17 21:55:12 +01:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-07-17 16:39:54 -07:00
2020-01-29 10:21:45 +01:00
2017-10-27 10:23:17 +02:00
2019-04-27 09:33:59 +02:00
2020-01-04 13:34:27 +01:00
2019-11-12 19:13:19 +01:00
2020-08-21 10:52:59 +02:00
2015-02-12 18:54:15 -08:00
2015-10-23 17:55:10 +09:00
2015-04-17 09:03:54 -04:00
2015-02-13 21:21:35 -08:00
2021-01-12 19:47:54 +01:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2018-04-24 09:32:04 +02:00
2015-11-06 17:50:42 -08:00
2019-04-27 09:33:47 +02:00
2018-12-21 14:09:49 +01:00
2015-02-12 18:54:15 -08:00
2015-11-05 16:34:48 -08:00
2018-08-17 20:56:45 +02:00
2016-09-24 10:07:43 +02:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2016-03-03 15:07:24 -08:00
2019-10-07 21:01:03 +02:00
2015-11-05 19:34:48 -08:00
2020-01-29 10:21:47 +01:00
2018-10-10 08:52:05 +02:00
2015-02-12 18:54:15 -08:00
2020-01-14 20:02:59 +01:00
2016-10-28 03:01:31 -04:00
2015-03-31 09:45:50 -06:00
2016-02-17 12:31:04 -08:00
2015-06-16 14:12:35 -04:00
2015-11-06 17:50:42 -08:00
2015-08-12 11:59:04 +02:00
2015-04-15 16:35:25 -07:00
2019-09-06 10:18:12 +02:00
2015-02-12 18:54:15 -08:00
2015-03-31 14:07:24 -04:00
2015-10-03 16:40:51 +01:00
2018-02-25 11:03:40 +01:00
2015-10-08 05:26:36 -07:00
2015-09-08 14:35:59 -07:00
2015-05-29 07:39:34 +10:00
2015-11-06 17:50:42 -08:00
2015-02-12 18:54:16 -08:00
2015-11-23 09:44:58 +01:00
2016-02-25 12:01:23 -08:00
2020-11-18 18:25:02 +01:00
2018-12-21 14:09:49 +01:00
2015-05-28 11:32:04 +09:30
2019-02-08 11:25:31 +01:00
2020-02-28 15:39:09 +01:00
2019-02-20 10:13:12 +01:00
2015-08-24 14:28:01 -06:00
2015-03-23 22:12:08 -04:00
2015-09-08 15:35:28 -07:00
2019-09-06 10:18:13 +02:00
2015-06-25 17:00:40 -07:00
2015-02-12 18:54:16 -08:00
2016-02-25 12:01:21 -08:00
2021-02-23 13:58:12 +01:00
2019-06-11 12:23:56 +02:00
2019-06-11 12:23:56 +02:00
2020-11-18 18:25:01 +01:00
2018-05-30 07:48:56 +02:00
2017-11-15 17:13:13 +01:00
2020-02-14 16:29:55 -05:00
2015-11-06 17:50:42 -08:00
2015-08-17 14:33:47 -07:00
2019-09-06 10:18:13 +02:00
2015-08-03 11:51:12 +02:00
2015-08-05 09:53:40 +02:00
2017-06-14 13:16:27 +02:00
2019-02-20 10:13:14 +01:00
2015-09-10 13:29:01 -07:00
2016-05-11 11:21:26 +02:00
2015-04-22 17:06:49 +02:00
2016-03-03 15:07:09 -08:00
2018-07-03 11:21:27 +02:00