Merge pull request #2978 from majianpeng/fix4

blkdev: using strncpy instead of strcpy.

Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2014-11-20 20:51:38 -08:00
commit 7d299528b5

View File

@ -29,9 +29,11 @@ bool block_device_support_discard(const char *devname)
{
bool can_trim = false;
char *p = strstr((char *)devname, "sd");
char name[32] = {0};
char name[32];
strncpy(name, p, sizeof(name) - 1);
name[sizeof(name) - 1] = '\0';
strcpy(name, p);
for (unsigned int i = 0; i < strlen(name); i++) {
if(isdigit(name[i])) {
name[i] = 0;