memcpy(mem + sizeof(part_t), addr, d->stats.st_size);
munmap(addr, d->stats.st_size);
- memset(p->name, 0, sizeof(p->name));
- strncpy(p->magic, MAGIC_PART, MAGIC_LENGTH);
- strncpy(p->name, d->partition_name, sizeof(p->name));
+ memset(p->name, 0, PART_NAME_LENGTH);
+ memcpy(p->magic, MAGIC_PART, MAGIC_LENGTH);
+ memcpy(p->name, d->partition_name, PART_NAME_LENGTH);
+
p->index = htonl(d->partition_index);
p->data_size = htonl(d->stats.st_size);
p->part_size = htonl(d->partition_length);
for (i = 0; i < im->part_count; ++i)
{
const part_data_t* d = &im->parts[i];
- INFO(" %10s: %8lld bytes (free: %8lld)\n",
+ INFO(" %10s: %8ld bytes (free: %8ld)\n",
d->partition_name,
d->stats.st_size,
d->partition_length - d->stats.st_size);
return -3;
}
if (d->stats.st_size > d->partition_length) {
- ERROR("File '%s' too big (%d) - max size: 0x%08X (exceeds %llu bytes)\n",
+ ERROR("File '%s' too big (%d) - max size: 0x%08X (exceeds %lu bytes)\n",
d->filename, i, d->partition_length,
d->stats.st_size - d->partition_length);
return -4;
switch (o) {
case 'v':
if (optarg)
- strncpy(im.version, optarg, sizeof(im.version));
+ strncpy(im.version, optarg, sizeof(im.version) - 1);
break;
case 'o':
if (optarg)
- strncpy(im.outputfile, optarg, sizeof(im.outputfile));
+ strncpy(im.outputfile, optarg, sizeof(im.outputfile) - 1);
break;
case 'm':
if (optarg)
- strncpy(im.magic, optarg, sizeof(im.magic));
+ strncpy(im.magic, optarg, sizeof(im.magic) - 1);
break;
case 'h':
usage(argv[0]);
return -1;
case 'k':
if (optarg)
- strncpy(kernelfile, optarg, sizeof(kernelfile));
+ strncpy(kernelfile, optarg, sizeof(kernelfile) - 1);
break;
case 'r':
if (optarg)
- strncpy(rootfsfile, optarg, sizeof(rootfsfile));
+ strncpy(rootfsfile, optarg, sizeof(rootfsfile) - 1);
break;
case 'B':
if (optarg)
- strncpy(board_name, optarg, sizeof(board_name));
+ strncpy(board_name, optarg, sizeof(board_name) - 1);
break;
}
}