diff options
author | François Perrad <francois.perrad@gadz.org> | 2019-03-20 15:09:19 +0100 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2019-03-20 22:09:19 +0800 |
commit | 28b6111db0f4ced931f2ce4b890a8d109904b8e2 (patch) | |
tree | 3ff28d553d9a52c18d302a13aef6bc46a6f1025c /scpmisc.c | |
parent | a0aa2749813331134452f80bb8a808bdc871ba41 (diff) |
use strlcpy & strlcat (#74)
* refactor checkpubkeyperms() with safe BSD functions
fix gcc8 warnings
```
svr-authpubkey.c: In function 'checkpubkeyperms':
svr-authpubkey.c:427:2: warning: 'strncat' specified bound 5 equals source length [-Wstringop-overflow=]
strncat(filename, "/.ssh", 5); /* strlen("/.ssh") == 5 */
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
svr-authpubkey.c:433:2: warning: 'strncat' specified bound 16 equals source length [-Wstringop-overflow=]
strncat(filename, "/authorized_keys", 16);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
see https://www.sudo.ws/todd/papers/strlcpy.html
* restore strlcpy in xstrdup
see original https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/xmalloc.c?rev=1.16
Diffstat (limited to 'scpmisc.c')
-rw-r--r-- | scpmisc.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -102,7 +102,7 @@ xstrdup(const char *str) len = strlen(str) + 1; cp = xmalloc(len); - strncpy(cp, str, len); + strlcpy(cp, str, len); return cp; } |