ncpfs: fix build warning of strncpy
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 7 Mar 2019 16:02:50 +0000 (17:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Mar 2019 21:04:52 +0000 (14:04 -0700)
Not upstream as ncpfs is long deleted.

Fix up two strncpy build warnings in ncp_get_charsets() by using strscpy
and the max size of the array.

It's not like anyone uses this code anyway, and this gets rid of two
build warnings so that we can see real warnings as they pop up over
time.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ncpfs/ioctl.c

index 0a3f9b594602341350afb79f27ba2cd8191468e8..37779ed3f79009f3f16c623b69528daf7e81993c 100644 (file)
@@ -233,7 +233,7 @@ ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg)
                len = strlen(server->nls_vol->charset);
                if (len > NCP_IOCSNAME_LEN)
                        len = NCP_IOCSNAME_LEN;
-               strncpy(user.codepage, server->nls_vol->charset, len);
+               strscpy(user.codepage, server->nls_vol->charset, NCP_IOCSNAME_LEN);
                user.codepage[len] = 0;
        }
 
@@ -243,7 +243,7 @@ ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg)
                len = strlen(server->nls_io->charset);
                if (len > NCP_IOCSNAME_LEN)
                        len = NCP_IOCSNAME_LEN;
-               strncpy(user.iocharset, server->nls_io->charset, len);
+               strscpy(user.iocharset, server->nls_io->charset, NCP_IOCSNAME_LEN);
                user.iocharset[len] = 0;
        }
        mutex_unlock(&server->root_setup_lock);