Commit 89b0e8c5 authored by minus's avatar minus

Fix length check

parent 34ebc959
......@@ -67,12 +67,12 @@ static gboolean on_fav_info(GIOChannel *source, GIOCondition condition, gpointer
char *line;
size_t len;
g_io_channel_read_line(source, &line, &len, NULL, NULL);
if (len < 13 || memcmp(line, "playing song", 12) == 0) {
if (len >= 13 && memcmp(line, "playing song", 12) == 0) {
char *hash = strtok(&line[13], " ");
if (fc->hash) free(fc->hash);
fc->hash = strdup(hash);
}
if (len < 20 || memcmp(line, "playing favorite", 16) == 0) {
if (len >= 22 && memcmp(line, "playing favorite", 16) == 0) {
fc->is_fav = strcmp(&line[17], "true\n") == 0;
midi_button_led(fc->sp->seq, fc->sp->port, fc->button, fc->is_fav ? BUTTON_LED_ON : BUTTON_LED_OFF);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment