void-packages/srcpkgs/wildmidi/patches/fix-midi_file.patch

18 lines
926 B
Diff

--- src/wildmidi.c 2018-11-24 09:55:50.000000000 +0100
+++ src/wildmidi.c 2020-01-23 17:07:12.497649804 +0100
@@ -1978,12 +1978,8 @@
if (!real_file) real_file = argv[optind];
else real_file++;
- strncpy(midi_file, real_file, strlen(real_file));
- midi_file[strlen(real_file)-4] = '.';
- midi_file[strlen(real_file)-3] = 'm';
- midi_file[strlen(real_file)-2] = 'i';
- midi_file[strlen(real_file)-1] = 'd';
-
+ snprintf(midi_file, sizeof(midi_file), "%.*s.mid",
+ (int)(strlen(real_file) - 4), real_file);
printf("\rWriting %s: %u bytes.\r\n", midi_file, getmidisize);
write_midi_output(getmidibuffer,getmidisize);
free(getmidibuffer);