This commit is contained in:
Pin
2024-05-21 21:08:35 -04:00
parent fdd643c528
commit e4d58ff94b
4 changed files with 52 additions and 14 deletions

View File

@@ -58,11 +58,17 @@ struct guestfs_inpsect_command *guestfs_inspect_zmsg_to_command(zmsg_t *external
zmsg_t *msg = zmsg_dup(external_msg);
struct guestfs_inpsect_command *res = malloc(sizeof(struct guestfs_inpsect_command));
if (!(zmsg_size(msg) > 2)) {
free(res);
zmsg_destroy(&msg);
return NULL;
}
res->name = zmsg_popstr(msg);
zframe_t *next = zmsg_pop(msg);
res->command = *(zframe_data(next));
free(next);
zframe_destroy(&next);
switch (res->command) {
case GUESTFS_COMMAND_LS:
next = zmsg_pop(msg);
@@ -86,9 +92,11 @@ struct guestfs_inpsect_command *guestfs_inspect_zmsg_to_command(zmsg_t *external
res->args.cat.paths[i] = zmsg_popstr(msg);
}
break;
default:
printf("Command not found\n");
}
zmsg_destroy(&msg);
return res;
}
@@ -108,7 +116,7 @@ void guestfs_inspect_command_destroy(struct guestfs_inpsect_command **c) {
free((*c)->args.cat.paths);
break;
}
free(*c);
*c = NULL;
}