| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2015 Karol Kosik <karo9@interia.eu> |
|---|
| 3 | 4 | * 2015 Samsung Electronics |
|---|
| .. | .. |
|---|
| 6 | 7 | * Based on tools/usb/usbip/libsrc/usbip_host_driver.c, which is: |
|---|
| 7 | 8 | * Copyright (C) 2011 matt mooney <mfm@muteddisk.com> |
|---|
| 8 | 9 | * 2005-2007 Takahiro Hirofuchi |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 12 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 13 | | - * (at your option) any later version. |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | | - * GNU General Public License for more details. |
|---|
| 19 | | - * |
|---|
| 20 | | - * You should have received a copy of the GNU General Public License |
|---|
| 21 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 22 | 10 | */ |
|---|
| 23 | 11 | |
|---|
| 24 | 12 | #include <fcntl.h> |
|---|
| .. | .. |
|---|
| 105 | 93 | copy_descr_attr16(dev, &descr, idProduct); |
|---|
| 106 | 94 | copy_descr_attr16(dev, &descr, bcdDevice); |
|---|
| 107 | 95 | |
|---|
| 108 | | - strncpy(dev->path, path, SYSFS_PATH_MAX); |
|---|
| 96 | + strncpy(dev->path, path, SYSFS_PATH_MAX - 1); |
|---|
| 97 | + dev->path[SYSFS_PATH_MAX - 1] = '\0'; |
|---|
| 109 | 98 | |
|---|
| 110 | 99 | dev->speed = USB_SPEED_UNKNOWN; |
|---|
| 111 | 100 | speed = udev_device_get_sysattr_value(sdev, "current_speed"); |
|---|
| .. | .. |
|---|
| 124 | 113 | dev->busnum = 0; |
|---|
| 125 | 114 | |
|---|
| 126 | 115 | name = udev_device_get_sysname(plat); |
|---|
| 127 | | - strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE); |
|---|
| 116 | + strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE - 1); |
|---|
| 117 | + dev->busid[SYSFS_BUS_ID_SIZE - 1] = '\0'; |
|---|
| 128 | 118 | return 0; |
|---|
| 129 | 119 | err: |
|---|
| 130 | 120 | fclose(fd); |
|---|