return rc;
}
-int get_device_by_fd(int fd, char *partition, char *device)
+int get_device_by_fd(int fd, char *partition, char *device, size_t max)
{
struct stat st;
int r = fstat(fd, &st);
if (!t) {
return -EINVAL;
}
- strcpy(partition, t);
+ strncpy(partition, t, max);
free(t);
dev_t diskdev;
- r = blkid_devno_to_wholedisk(devid, device, PATH_MAX, &diskdev);
+ r = blkid_devno_to_wholedisk(devid, device, max, &diskdev);
if (r < 0) {
return -EINVAL;
}
// from an fd
extern int block_device_discard(int fd, int64_t offset, int64_t len);
extern int get_block_device_size(int fd, int64_t *psize);
-extern int get_device_by_fd(int fd, char* partition, char* device);
+extern int get_device_by_fd(int fd, char* partition, char* device, size_t max);
// from a uuid
extern int get_device_by_uuid(uuid_d dev_uuid, const char* label,
}
{
- char partition[1024], devname[1024];
- r = get_device_by_fd(fd_buffered, partition, devname);
+ char partition[PATH_MAX], devname[PATH_MAX];
+ r = get_device_by_fd(fd_buffered, partition, devname, sizeof(devname));
if (r < 0) {
derr << "unable to get device name for " << path << ": "
<< cpp_strerror(r) << dendl;
(*pm)[prefix + "access_mode"] = "blk";
char partition_path[PATH_MAX];
char dev_node[PATH_MAX];
- int rc = get_device_by_fd(fd_buffered, partition_path, dev_node);
+ int rc = get_device_by_fd(fd_buffered, partition_path, dev_node, PATH_MAX);
switch (rc) {
case -EOPNOTSUPP:
case -EINVAL: