Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape file name commas in startup command #67

Merged
merged 3 commits into from
Nov 7, 2020
Merged

Escape file name commas in startup command #67

merged 3 commits into from
Nov 7, 2020

Conversation

Aerocatia
Copy link
Contributor

This fixes #65

softmmu/vl.c Outdated
@@ -2921,7 +2945,7 @@ void qemu_init(int argc, char **argv, char **envp)
xemu_settings_get_bool(XEMU_SETTINGS_SYSTEM_SHORTANIM, &short_animation);

fake_argv[fake_argc++] = g_strdup_printf("xbox%s%s%s",
strlen(bootrom_path) > 0 ? g_strdup_printf(",bootrom=%s", bootrom_path) : "", // Leak
strlen(bootrom_path) > 0 ? g_strdup_printf(",bootrom=%s", strdup_double_commas(bootrom_path)) : "", // Leak
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's free the escaped paths after using g_strdup_printf

softmmu/vl.c Outdated
// Duplicate commas to escape them
static char *strdup_double_commas(const char *input) {
size_t length = 0;
for(const char *i = input; *i; i++) {
Copy link
Member

@mborgerson mborgerson Nov 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: Please have a space after for and while, if below as well

softmmu/vl.c Outdated
char *output = malloc(length + 1);
char *out = output;
const char *in = input;
while(*in) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest a slightly more succinct version:

const char *in = input;
char *out = output;
while (*in) {
	if (*in == ',') {
		*(out++) = ',';
	}
	*(out++) = *(in++);
}

@mborgerson
Copy link
Member

Looks good, just some minor changes requested. Thanks for looking into it!

@mborgerson mborgerson merged commit f827615 into xemu-project:master Nov 7, 2020
@mborgerson
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Commas in file names are unsupported by the Qemu command line interface potentially breaking xemu startup.
2 participants