if (!(dev->flags & DEV_REGULAR) || size2)
use_plain_read = 0;
- if (!(buf = zalloc(size + size2))) {
+ /* Ensure there is extra '\0' after end of buffer since we pass
+ * buffer to funtions like strtoll() */
+ if (!(buf = zalloc(size + size2 + 1))) {
log_error("Failed to allocate circular buffer.");
return 0;
}
fmt->ops = &_text_handler;
fmt->name = FMT_TEXT_NAME;
fmt->alias = FMT_TEXT_ALIAS;
- fmt->orphan_vg_name = ORPHAN_VG_NAME(FMT_TEXT_NAME);
+ strncpy(fmt->orphan_vg_name, ORPHAN_VG_NAME(FMT_TEXT_NAME), sizeof(fmt->orphan_vg_name));
fmt->features = FMT_SEGMENTS | FMT_TAGS | FMT_PRECOMMIT |
FMT_UNLIMITED_VOLS | FMT_RESIZE_PV |
FMT_UNLIMITED_STRIPESIZE | FMT_CONFIG_PROFILE |
{
struct lvmcache_vgsummary vgsummary;
char pvid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
struct lvmcache_info *info;
const struct format_type *fmt = labeller->fmt;
struct label_header *lh = (struct label_header *) label_buf;
pvhdr = (struct pv_header *) ((char *) label_buf + xlate32(lh->offset_xl));
memcpy(pvid, &pvhdr->pv_uuid, ID_LEN);
+ strncpy(vgid, FMT_TEXT_ORPHAN_VG_NAME, ID_LEN);
/*
* FIXME: stop adding the device to lvmcache initially as an orphan
* Other reasons for lvmcache_add to return NULL are internal errors.
*/
if (!(info = lvmcache_add(cmd, labeller, pvid, dev, label_sector,
- FMT_TEXT_ORPHAN_VG_NAME,
- FMT_TEXT_ORPHAN_VG_NAME, 0, is_duplicate)))
+ vgid,
+ vgid, 0, is_duplicate)))
return_0;
lvmcache_set_device_size(info, xlate64(pvhdr->device_size_xl));
struct labeller *labeller;
const char *name;
const char *alias;
- const char *orphan_vg_name;
+ char orphan_vg_name[ID_LEN];
struct volume_group *orphan_vg; /* Only one ever exists. */
uint32_t features;
void *library;
assert(ID_LEN == 32);
+ if (id->uuid[0] == '#') {
+ (void) dm_strncpy(buffer, (char*)id->uuid, size);
+ return 1;
+ }
+
/* split into groups separated by dashes */
if (size < (32 + 6 + 1)) {
if (size > 0)
$(Q) set -o pipefail && \
( cat $(srcdir)/license.inc && \
echo "/* Do not edit. This file is generated by the Makefile. */" && \
- echo -en "const char _command_input[] =\n\n\"" && \
+ echo -en "static const char _command_input[] =\n\n\"" && \
$(EGREP) -v '^#|\-\-\-|^$$' $(srcdir)/command-lines.in | $(AWK) 'BEGIN {ORS = "\\n\"\n\""} //' && \
- echo "\\n\";" \
+ echo "\\n\\n\";" \
) > $@
$(SOURCES:%.c=%.d) $(SOURCES2:%.c=%.d): command-lines-input.h command-count.h cmds.h
}
if (strchr(long_opt, '[')) {
- for (i = 0; i < sizeof(long_opt_name) - 1; ++long_opt, ++i) {
+ for (i = 0; *long_opt && i < sizeof(long_opt_name) - 1; ++long_opt, ++i) {
if (i < (sizeof(long_opt_name) - 8))
switch(*long_opt) {
case '[':