code:
Author: R Veera Kumar 2020 <vkor@vkten.in>
Desc:
 1) Fixes download of exchange rates by specifying SSL CA certificates bundle
    file while using libcurl (Since libcurl in guix is compiled without using
    a default CA cert bundle file)
 2) Like above fix for using https site in another case

diff -uNr libqalculate-3.8.0/libqalculate/Calculator-definitions.cc libqalculate-3.8.0.new/libqalculate/Calculator-definitions.cc
--- libqalculate-3.8.0/libqalculate/Calculator-definitions.cc	2020-02-16 15:08:29.000000000 +0530
+++ libqalculate-3.8.0.new/libqalculate/Calculator-definitions.cc	2020-04-17 21:27:36.386039369 +0530
@@ -3610,6 +3610,7 @@
 	curl = curl_easy_init();
 	if(!curl) {return false;}
 	curl_easy_setopt(curl, CURLOPT_URL, getExchangeRatesUrl(1).c_str());
+	curl_easy_setopt(curl, CURLOPT_CAINFO, getenv("SSL_CERT_FILE"));
 	curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
 	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
 	curl_easy_setopt(curl, CURLOPT_WRITEDATA, &sbuffer);
@@ -3663,6 +3664,7 @@

 		sbuffer = "";
 		curl_easy_setopt(curl, CURLOPT_URL, getExchangeRatesUrl(2).c_str());
+		curl_easy_setopt(curl, CURLOPT_CAINFO, getenv("SSL_CERT_FILE"));
 		curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
 		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
 		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &sbuffer);
@@ -3687,6 +3689,7 @@

 		sbuffer = "";
 		curl_easy_setopt(curl, CURLOPT_URL, getExchangeRatesUrl(3).c_str());
+		curl_easy_setopt(curl, CURLOPT_CAINFO, getenv("SSL_CERT_FILE"));
 		curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
 		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
 		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &sbuffer);
@@ -3710,6 +3713,7 @@

 		sbuffer = "";
 		curl_easy_setopt(curl, CURLOPT_URL, getExchangeRatesUrl(4).c_str());
+		curl_easy_setopt(curl, CURLOPT_CAINFO, getenv("SSL_CERT_FILE"));
 		curl_easy_setopt(curl, CURLOPT_TIMEOUT, (timeout > 4 && n <= 0) ? 4 : timeout);
 		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
 		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &sbuffer);
diff -uNr libqalculate-3.8.0/libqalculate/util.cc libqalculate-3.8.0.new/libqalculate/util.cc
--- libqalculate-3.8.0/libqalculate/util.cc	2019-12-14 22:56:45.000000000 +0530
+++ libqalculate-3.8.0.new/libqalculate/util.cc	2020-04-17 21:12:17.259674572 +0530
@@ -769,6 +769,7 @@
 	curl = curl_easy_init();
 	if(!curl) {return -1;}
 	curl_easy_setopt(curl, CURLOPT_URL, "https://qalculate.github.io/CURRENT_VERSIONS");
+	curl_easy_setopt(curl, CURLOPT_CAINFO, getenv("SSL_CERT_FILE"));
 	curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
 	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
 	curl_easy_setopt(curl, CURLOPT_WRITEDATA, &sbuffer);


code:
Submitted By: Ken Moffat <ken at linuxfromscratch dot org>
Date: 2018-05-12
Initial Package Version: 1.2.4
Upstream Status: Defunct
Origin: Gentoo
Description: Accumulated fixes up to and including building with ffmpeg-4

From gentoo, their libav-9.patch, ffmpeg2.patch, CVE-2016-2399.patch,
ffmpeg29.patch, ffmpeg4.patch, and seds to files lqt_ffmpeg.c, video.c,
audio.c in plugins/ffmpeg/ to change CODEC_ID to AV_CODEC_ID.

Build-tested only.

diff -Naur a/plugins/ffmpeg/audio.c b/plugins/ffmpeg/audio.c
--- a/plugins/ffmpeg/audio.c	2012-03-29 20:44:28.000000000 +0100
+++ b/plugins/ffmpeg/audio.c	2018-05-11 23:15:21.057985300 +0100
@@ -45,6 +45,11 @@
 #define ENCODE_AUDIO 1
 #endif

+#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
+/* from libavcodec/avcodec.h dated Dec 23 2012 */
+#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
+#endif
+
 /* The following code was ported from gmerlin_avdecoder (http://gmerlin.sourceforge.net) */

 /* MPEG Audio header parsing code */
@@ -540,7 +545,7 @@

 #if DECODE_AUDIO3 || DECODE_AUDIO4
     codec->pkt.data = codec->chunk_buffer;
-    codec->pkt.size = packet_size + FF_INPUT_BUFFER_PADDING_SIZE;
+    codec->pkt.size = packet_size + AV_INPUT_BUFFER_PADDING_SIZE;

 #if DECODE_AUDIO4
     frame_bytes = avcodec_decode_audio4(codec->avctx, &f,
@@ -578,7 +583,7 @@
                                          (codec->sample_buffer_end - codec->sample_buffer_start)],
                   &bytes_decoded,
                   codec->chunk_buffer,
-                  packet_size + FF_INPUT_BUFFER_PADDING_SIZE);
+                  packet_size + AV_INPUT_BUFFER_PADDING_SIZE);
     if(frame_bytes < 0)
       {
       lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "avcodec_decode_audio2 error");
@@ -626,7 +631,7 @@
     {
     /* If the codec is mp3, make sure to decode the very last frame */

-    if((codec->avctx->codec_id == CODEC_ID_MP3) &&
+    if((codec->avctx->codec_id == AV_CODEC_ID_MP3) &&
        (codec->bytes_in_chunk_buffer >= 4))
       {
       if(!mpa_decode_header(&mph, codec->chunk_buffer, (const mpa_header*)0))
@@ -640,13 +645,13 @@
         return 0;
         }

-      if(codec->chunk_buffer_alloc < mph.frame_bytes + FF_INPUT_BUFFER_PADDING_SIZE)
+      if(codec->chunk_buffer_alloc < mph.frame_bytes + AV_INPUT_BUFFER_PADDING_SIZE)
         {
-        codec->chunk_buffer_alloc = mph.frame_bytes + FF_INPUT_BUFFER_PADDING_SIZE;
+        codec->chunk_buffer_alloc = mph.frame_bytes + AV_INPUT_BUFFER_PADDING_SIZE;
         codec->chunk_buffer = realloc(codec->chunk_buffer, codec->chunk_buffer_alloc);
         }
       memset(codec->chunk_buffer + codec->bytes_in_chunk_buffer, 0,
-             mph.frame_bytes - codec->bytes_in_chunk_buffer + FF_INPUT_BUFFER_PADDING_SIZE);
+             mph.frame_bytes - codec->bytes_in_chunk_buffer + AV_INPUT_BUFFER_PADDING_SIZE);
       num_samples = mph.samples_per_frame;
       codec->bytes_in_chunk_buffer = mph.frame_bytes;
       }
@@ -690,12 +695,12 @@
     {

-    /* BIG NOTE: We pass extra FF_INPUT_BUFFER_PADDING_SIZE for the buffer size
+    /* BIG NOTE: We pass extra AV_INPUT_BUFFER_PADDING_SIZE for the buffer size
        because we know, that lqt_read_audio_chunk allocates 16 extra bytes for us */

     /* Some really broken mp3 files have the header bytes split across 2 chunks */

-    if(codec->avctx->codec_id == CODEC_ID_MP3)
+    if(codec->avctx->codec_id == AV_CODEC_ID_MP3)
       {
       if(codec->bytes_in_chunk_buffer < 4)
         {
@@ -756,7 +761,7 @@

 #if DECODE_AUDIO3 || DECODE_AUDIO4
     codec->pkt.data = &codec->chunk_buffer[bytes_used];
-    codec->pkt.size = codec->bytes_in_chunk_buffer + FF_INPUT_BUFFER_PADDING_SIZE;
+    codec->pkt.size = codec->bytes_in_chunk_buffer + AV_INPUT_BUFFER_PADDING_SIZE;

 #if DECODE_AUDIO4

@@ -793,7 +798,7 @@
                                                   (codec->sample_buffer_end - codec->sample_buffer_start)],
                             &bytes_decoded,
                             &codec->chunk_buffer[bytes_used],
-                            codec->bytes_in_chunk_buffer + FF_INPUT_BUFFER_PADDING_SIZE);
+                            codec->bytes_in_chunk_buffer + AV_INPUT_BUFFER_PADDING_SIZE);
 #endif
     if(frame_bytes < 0)
       {
@@ -806,7 +811,7 @@

     if(bytes_decoded < 0)
       {
-      if(codec->avctx->codec_id == CODEC_ID_MP3)
+      if(codec->avctx->codec_id == AV_CODEC_ID_MP3)
         {
         /* For mp3, bytes_decoded < 0 means, that the frame should be muted */
         memset(&codec->sample_buffer[track_map->channels * (codec->sample_buffer_end -
@@ -833,7 +838,7 @@
         }
       }

-    /* This happens because ffmpeg adds FF_INPUT_BUFFER_PADDING_SIZE to the bytes returned */
+    /* This happens because ffmpeg adds AV_INPUT_BUFFER_PADDING_SIZE to the bytes returned */

     if(codec->bytes_in_chunk_buffer < 0)
       codec->bytes_in_chunk_buffer = 0;
@@ -866,8 +871,8 @@
   quicktime_audio_map_t *track_map = &file->atracks[track];
   quicktime_ffmpeg_audio_codec_t *codec = track_map->codec->priv;

-  if((codec->decoder->id == CODEC_ID_MP2) ||
-     (codec->decoder->id == CODEC_ID_MP3))
+  if((codec->decoder->id == AV_CODEC_ID_MP2) ||
+     (codec->decoder->id == AV_CODEC_ID_MP3))
     {
     mpa_header h;
     uint32_t header;
@@ -909,7 +914,7 @@
     else
       track_map->ci.bitrate = h.bitrate;
     }
-  else if(codec->decoder->id == CODEC_ID_AC3)
+  else if(codec->decoder->id == AV_CODEC_ID_AC3)
     {
     a52_header h;
     uint8_t * ptr;
@@ -986,7 +991,7 @@
 #endif
     /* Some codecs need extra stuff */

-    if(codec->decoder->id == CODEC_ID_ALAC)
+    if(codec->decoder->id == AV_CODEC_ID_ALAC)
       {
       header = quicktime_wave_get_user_atom(track_map->track, "alac", &header_len);
       if(header)
@@ -995,7 +1000,7 @@
         codec->avctx->extradata_size = header_len;
         }
       }
-    if(codec->decoder->id == CODEC_ID_QDM2)
+    if(codec->decoder->id == AV_CODEC_ID_QDM2)
       {
       header = quicktime_wave_get_user_atom(track_map->track, "QDCA", &header_len);
       if(header)
@@ -1261,7 +1266,7 @@
     pkt.data = codec->chunk_buffer;
     pkt.size = codec->chunk_buffer_alloc;

-    avcodec_get_frame_defaults(&f);
+    av_frame_unref(&f);
     f.nb_samples = codec->avctx->frame_size;

     avcodec_fill_audio_frame(&f, channels, codec->avctx->sample_fmt,
@@ -1495,9 +1500,9 @@
     codec_base->decode_audio = lqt_ffmpeg_decode_audio;
   codec_base->set_parameter = set_parameter;

-  if((decoder->id == CODEC_ID_MP3) || (decoder->id == CODEC_ID_MP2))
+  if((decoder->id == AV_CODEC_ID_MP3) || (decoder->id == AV_CODEC_ID_MP2))
     codec_base->read_packet = read_packet_mpa;
-  else if(decoder->id == CODEC_ID_AC3)
+  else if(decoder->id == AV_CODEC_ID_AC3)
     {
     codec_base->write_packet = write_packet_ac3;
     codec_base->read_packet = read_packet_ac3;
diff -Naur a/plugins/ffmpeg/ffmpeg.h b/plugins/ffmpeg/ffmpeg.h
--- a/plugins/ffmpeg/ffmpeg.h	2012-02-15 19:48:30.000000000 +0000
+++ b/plugins/ffmpeg/ffmpeg.h	2018-05-11 23:10:24.204992468 +0100
@@ -27,6 +27,7 @@

 #include <quicktime/qtprivate.h>
 #include AVCODEC_HEADER
+#include <libavutil/mem.h>

 void quicktime_init_video_codec_ffmpeg(quicktime_codec_t * codec,
                                        quicktime_video_map_t *vtrack,
diff -Naur a/plugins/ffmpeg/lqt_ffmpeg.c b/plugins/ffmpeg/lqt_ffmpeg.c
--- a/plugins/ffmpeg/lqt_ffmpeg.c	2012-02-15 19:48:30.000000000 +0000
+++ b/plugins/ffmpeg/lqt_ffmpeg.c	2018-05-11 23:15:07.583985628 +0100
@@ -386,7 +386,7 @@
 struct CODECIDMAP codecidmap_v[] =
   {
     {
-      .id = CODEC_ID_MPEG1VIDEO,
+      .id = AV_CODEC_ID_MPEG1VIDEO,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -397,7 +397,7 @@
       .wav_ids = { LQT_WAV_ID_NONE }
     },
     {
-      .id = CODEC_ID_MPEG4,
+      .id = AV_CODEC_ID_MPEG4,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -415,7 +415,7 @@
       .compression_id = LQT_COMPRESSION_MPEG4_ASP,
     },
     {
-      .id = CODEC_ID_MSMPEG4V1,
+      .id = AV_CODEC_ID_MSMPEG4V1,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -426,7 +426,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_MSMPEG4V2,
+      .id = AV_CODEC_ID_MSMPEG4V2,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -437,7 +437,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_MSMPEG4V3,
+      .id = AV_CODEC_ID_MSMPEG4V3,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -453,7 +453,7 @@
       .do_encode = 1,
     },
     {
-      .id = CODEC_ID_MSMPEG4V3,
+      .id = AV_CODEC_ID_MSMPEG4V3,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -468,7 +468,7 @@
     },
 #if 0
     {
-      .id = CODEC_ID_WMV1,
+      .id = AV_CODEC_ID_WMV1,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -481,7 +481,7 @@
     },
 #endif
     {
-      .id = CODEC_ID_H263,
+      .id = AV_CODEC_ID_H263,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -493,7 +493,7 @@
       .compatibility_flags = LQT_FILE_QT_OLD | LQT_FILE_QT | LQT_FILE_MP4 | LQT_FILE_3GP,
     },
     {
-      .id = CODEC_ID_H263,
+      .id = AV_CODEC_ID_H263,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -508,7 +508,7 @@
       .do_encode = 1,
     },
     {
-      .id = CODEC_ID_H264,
+      .id = AV_CODEC_ID_H264,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -519,7 +519,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_H263P,
+      .id = AV_CODEC_ID_H263P,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -533,7 +533,7 @@
       .do_encode = 1,
     },
     {
-      .id = CODEC_ID_H263I,
+      .id = AV_CODEC_ID_H263I,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -544,7 +544,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_SVQ1,
+      .id = AV_CODEC_ID_SVQ1,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -555,7 +555,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_SVQ3,
+      .id = AV_CODEC_ID_SVQ3,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -566,7 +566,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_MJPEG,
+      .id = AV_CODEC_ID_MJPEG,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -580,7 +580,7 @@
       .do_encode = 1,
     },
     {
-      .id = CODEC_ID_MJPEGB,
+      .id = AV_CODEC_ID_MJPEGB,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -594,7 +594,7 @@
     },
 #if LIBAVCODEC_BUILD >= 3346688
     {
-      .id = CODEC_ID_TARGA,
+      .id = AV_CODEC_ID_TARGA,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -606,7 +606,7 @@
 #endif
 #if LIBAVCODEC_BUILD >= 3347456
     {
-      .id = CODEC_ID_TIFF,
+      .id = AV_CODEC_ID_TIFF,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -617,7 +617,7 @@
     },
 #endif
     {
-      .id = CODEC_ID_8BPS,
+      .id = AV_CODEC_ID_8BPS,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -627,7 +627,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_INDEO3,
+      .id = AV_CODEC_ID_INDEO3,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -638,7 +638,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_RPZA,
+      .id = AV_CODEC_ID_RPZA,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -648,7 +648,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_SMC,
+      .id = AV_CODEC_ID_SMC,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -658,7 +658,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_CINEPAK,
+      .id = AV_CODEC_ID_CINEPAK,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -669,7 +669,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_CYUV,
+      .id = AV_CODEC_ID_CYUV,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -680,7 +680,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_QTRLE,
+      .id = AV_CODEC_ID_QTRLE,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -693,7 +693,7 @@
       .encoding_colormodels = (int[]){ BC_RGB888, BC_RGBA8888, LQT_COLORMODEL_NONE },
     },
     {
-      .id = CODEC_ID_MSRLE,
+      .id = AV_CODEC_ID_MSRLE,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -703,7 +703,7 @@
       .wav_ids = { LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_DVVIDEO,
+      .id = AV_CODEC_ID_DVVIDEO,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -719,7 +719,7 @@
       .image_sizes = image_sizes_dv,
     },
     {
-      .id = CODEC_ID_DVVIDEO,
+      .id = AV_CODEC_ID_DVVIDEO,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -735,7 +735,7 @@
       .image_sizes = image_sizes_dv,
     },
     {
-      .id = CODEC_ID_DVVIDEO,
+      .id = AV_CODEC_ID_DVVIDEO,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -751,7 +751,7 @@
     },
     /* DVCPRO HD (decoding only for now) */
     {
-      .id = CODEC_ID_DVVIDEO,
+      .id = AV_CODEC_ID_DVVIDEO,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -772,7 +772,7 @@
       // .do_encode = 1
     },
     {
-      .id = CODEC_ID_FFVHUFF,
+      .id = AV_CODEC_ID_FFVHUFF,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -785,7 +785,7 @@
       .do_encode = 1
     },
     {
-      .id = CODEC_ID_FFV1,
+      .id = AV_CODEC_ID_FFV1,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -801,7 +801,7 @@
     },
 #if LIBAVCODEC_BUILD >= 3352576
     {
-      .id = CODEC_ID_DNXHD,
+      .id = AV_CODEC_ID_DNXHD,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -817,7 +817,7 @@
     },
 #endif
     {
-      .id = CODEC_ID_MPEG2VIDEO,
+      .id = AV_CODEC_ID_MPEG2VIDEO,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -839,7 +839,7 @@
 struct CODECIDMAP codecidmap_a[] =
   {
     {
-      .id = CODEC_ID_MP3,
+      .id = AV_CODEC_ID_MP3,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -851,7 +851,7 @@
       .wav_ids = { 0x50, 0x55, LQT_WAV_ID_NONE },
     },
     {
-      .id = CODEC_ID_MP2,
+      .id = AV_CODEC_ID_MP2,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -866,7 +866,7 @@
       .compression_id = LQT_COMPRESSION_MP2,
     },
     {
-      .id = CODEC_ID_AC3,
+      .id = AV_CODEC_ID_AC3,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -881,7 +881,7 @@
       .compression_id = LQT_COMPRESSION_AC3,
     },
     {
-      .id = CODEC_ID_QDM2,
+      .id = AV_CODEC_ID_QDM2,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -896,7 +896,7 @@
 #if 1
     /* Doesn't work as long as audio chunks are not split into VBR "Samples" */
     {
-      .id = CODEC_ID_ALAC,
+      .id = AV_CODEC_ID_ALAC,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -909,7 +909,7 @@
 #if 1
     /* Sounds ugly */
     {
-      .id = CODEC_ID_ADPCM_MS,
+      .id = AV_CODEC_ID_ADPCM_MS,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
@@ -922,7 +922,7 @@
 #if 1
     /* Sounds ugly */
     {
-      .id = CODEC_ID_ADPCM_IMA_WAV,
+      .id = AV_CODEC_ID_ADPCM_IMA_WAV,
       .index = -1,
       .encoder = NULL,
       .decoder = NULL,
diff -Naur a/plugins/ffmpeg/params.c b/plugins/ffmpeg/params.c
--- a/plugins/ffmpeg/params.c	2012-03-07 14:10:41.000000000 +0000
+++ b/plugins/ffmpeg/params.c	2018-05-11 23:11:59.803990160 +0100
@@ -101,6 +101,17 @@
     }                                           \
   }

+#define PARAM_DICT_INT(name, dict_name)             \
+  {                                                 \
+  if(!strcasecmp(name, key))                        \
+    {                                               \
+    char buf[128];                                  \
+    snprintf(buf, sizeof(buf), "%d", *(int*)value); \
+    av_dict_set(options, dict_name, buf, 0);        \
+    found = 1;                                      \
+    }                                               \
+  }
+
 #define PARAM_DICT_FLAG(name, dict_name)        \
   {                                             \
   if(!strcasecmp(name, key))                    \
@@ -113,16 +124,6 @@
   }

-enum_t me_method[] =
-  {
-    { "Zero",  ME_ZERO },
-    { "Phods", ME_PHODS },
-    { "Log",   ME_LOG },
-    { "X1",    ME_X1 },
-    { "Epzs",  ME_EPZS },
-    { "Full",  ME_FULL }
-  };
-
 enum_t prediction_method[] =
   {
     { "Left",   FF_PRED_LEFT },
@@ -152,15 +153,6 @@
     { "Rate distoration",     FF_MB_DECISION_RD }
   };

-enum_t coder_type[] =
-  {
-    { "VLC",                  FF_CODER_TYPE_VLC },
-    { "Arithmetic",           FF_CODER_TYPE_AC },
-    { "Raw",                  FF_CODER_TYPE_RAW },
-    { "RLE",                  FF_CODER_TYPE_RLE },
-    { "Deflate",              FF_CODER_TYPE_DEFLATE },
-  };
-
 #define PARAM_ENUM(name, var, arr) \
   if(!strcasecmp(key, name)) \
     { \
@@ -192,7 +184,7 @@
   PARAM_INT_SCALE("ff_bit_rate_audio",bit_rate,1000);
   PARAM_INT_SCALE("ff_bit_rate_video",bit_rate,1000);
   PARAM_INT_SCALE("ff_bit_rate_tolerance",bit_rate_tolerance,1000);
-  PARAM_ENUM("ff_me_method",me_method,me_method);
+  PARAM_DICT_INT("ff_me_method","motion-est");
   PARAM_INT("ff_gop_size",gop_size);
   PARAM_FLOAT("ff_qcompress",qcompress);
   PARAM_FLOAT("ff_qblur",qblur);
@@ -202,17 +194,23 @@
   PARAM_INT("ff_max_b_frames",max_b_frames);
   PARAM_FLOAT("ff_b_quant_factor",b_quant_factor);
   PARAM_INT("ff_b_frame_strategy",b_frame_strategy);
+
+#if LIBAVCODEC_VERSION_MAJOR >= 55
+  PARAM_DICT_INT("ff_luma_elim_threshold","luma_elim_threshold");
+  PARAM_DICT_INT("ff_chroma_elim_threshold","chroma_elim_threshold");
+#else
   PARAM_INT("ff_luma_elim_threshold",luma_elim_threshold);
   PARAM_INT("ff_chroma_elim_threshold",chroma_elim_threshold);
+#endif
+
   PARAM_INT("ff_strict_std_compliance",strict_std_compliance);
   PARAM_QP2LAMBDA("ff_b_quant_offset",b_quant_offset);
   PARAM_INT("ff_rc_min_rate",rc_min_rate);
   PARAM_INT("ff_rc_max_rate",rc_max_rate);
   PARAM_INT_SCALE("ff_rc_buffer_size",rc_buffer_size,1000);
-  PARAM_FLOAT("ff_rc_buffer_aggressivity",rc_buffer_aggressivity);
   PARAM_FLOAT("ff_i_quant_factor",i_quant_factor);
   PARAM_QP2LAMBDA("ff_i_quant_offset",i_quant_offset);
-  PARAM_FLOAT("ff_rc_initial_cplx",rc_initial_cplx);
+  PARAM_DICT_INT("ff_rc_initial_cplx","rc_init_cplx");
   PARAM_FLOAT("ff_lumi_masking",lumi_masking);
   PARAM_FLOAT("ff_temporal_cplx_masking",temporal_cplx_masking);
   PARAM_FLOAT("ff_spatial_cplx_masking",spatial_cplx_masking);
@@ -237,58 +235,68 @@
   PARAM_INT("ff_me_range",me_range);
   PARAM_ENUM("ff_mb_decision",mb_decision,mb_decision);
   PARAM_INT("ff_scenechange_threshold",scenechange_threshold);
-  PARAM_QP2LAMBDA("ff_lmin", lmin);
-  PARAM_QP2LAMBDA("ff_lmax", lmax);
+  PARAM_DICT_INT("ff_lmin", "lmin");
+  PARAM_DICT_INT("ff_lmax", "lmax");
   PARAM_INT("ff_noise_reduction",noise_reduction);
   PARAM_INT_SCALE("ff_rc_initial_buffer_occupancy",rc_initial_buffer_occupancy,1000);
+
+#if LIBAVCODEC_VERSION_MAJOR >= 55
+  PARAM_DICT_INT("ff_inter_threshold","inter_threshold");
+  PARAM_DICT_INT("ff_quantizer_noise_shaping","quantizer_noise_shaping");
+#else
   PARAM_INT("ff_inter_threshold",inter_threshold);
   PARAM_INT("ff_quantizer_noise_shaping",quantizer_noise_shaping);
+#endif
+
   PARAM_INT("ff_thread_count",thread_count);
-  PARAM_INT("ff_me_threshold",me_threshold);
-  PARAM_INT("ff_mb_threshold",mb_threshold);
   PARAM_INT("ff_nsse_weight",nsse_weight);
-  PARAM_FLOAT("ff_border_masking",border_masking);
+  PARAM_DICT_INT("ff_border_masking","border_mask");
   PARAM_QP2LAMBDA("ff_mb_lmin", mb_lmin);
   PARAM_QP2LAMBDA("ff_mb_lmax", mb_lmax);
   PARAM_INT("ff_me_penalty_compensation",me_penalty_compensation);
   PARAM_INT("ff_bidir_refine",bidir_refine);
   PARAM_INT("ff_brd_scale",brd_scale);
-  PARAM_INT("ff_scenechange_factor",scenechange_factor);
-  PARAM_FLAG("ff_flag_qscale",CODEC_FLAG_QSCALE);
-  PARAM_FLAG("ff_flag_4mv",CODEC_FLAG_4MV);
-  PARAM_FLAG("ff_flag_qpel",CODEC_FLAG_QPEL);
-  PARAM_FLAG("ff_flag_gmc",CODEC_FLAG_GMC);
-  PARAM_FLAG("ff_flag_mv0",CODEC_FLAG_MV0);
+  PARAM_FLAG("ff_flag_qscale",AV_CODEC_FLAG_QSCALE);
+  PARAM_FLAG("ff_flag_4mv",AV_CODEC_FLAG_4MV);
+  PARAM_FLAG("ff_flag_qpel",AV_CODEC_FLAG_QPEL);
+  PARAM_DICT_FLAG("ff_flag_gmc","gmc");
+  PARAM_DICT_FLAG("ff_flag_mv0","mpv_flags");
   //  PARAM_FLAG("ff_flag_part",CODEC_FLAG_PART); // Unused
-  PARAM_FLAG("ff_flag_gray",CODEC_FLAG_GRAY);
-  PARAM_FLAG("ff_flag_emu_edge",CODEC_FLAG_EMU_EDGE);
-  PARAM_FLAG("ff_flag_normalize_aqp",CODEC_FLAG_NORMALIZE_AQP);
+  PARAM_FLAG("ff_flag_gray",AV_CODEC_FLAG_GRAY);
+  PARAM_DICT_FLAG("ff_flag_normalize_aqp","naq");
   //  PARAM_FLAG("ff_flag_alt_scan",CODEC_FLAG_ALT_SCAN); // Unused
 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
   PARAM_FLAG("ff_flag_trellis_quant",CODEC_FLAG_TRELLIS_QUANT);
 #else
   PARAM_INT("ff_trellis",trellis);
 #endif
-  PARAM_FLAG("ff_flag_bitexact",CODEC_FLAG_BITEXACT);
-  PARAM_FLAG("ff_flag_ac_pred",CODEC_FLAG_AC_PRED);
+  PARAM_FLAG("ff_flag_bitexact",AV_CODEC_FLAG_BITEXACT);
+  PARAM_FLAG("ff_flag_ac_pred",AV_CODEC_FLAG_AC_PRED);
   //  PARAM_FLAG("ff_flag_h263p_umv",CODEC_FLAG_H263P_UMV); // Unused
-  PARAM_FLAG("ff_flag_cbp_rd",CODEC_FLAG_CBP_RD);
-  PARAM_FLAG("ff_flag_qp_rd",CODEC_FLAG_QP_RD);
+
+#if LIBAVCODEC_VERSION_MAJOR >= 55
+  PARAM_DICT_FLAG("ff_flag_cbp_rd","cbp_rd");
+  PARAM_DICT_FLAG("ff_flag_qp_rd","qp_rd");
+  PARAM_DICT_FLAG("ff_flag2_strict_gop","strict_gop");
+#else
+  PARAM_FLAG("ff_flag_cbp_rd",AV_CODEC_FLAG_CBP_RD);
+  PARAM_FLAG("ff_flag_qp_rd",AV_CODEC_FLAG_QP_RD);
+  PARAM_FLAG2("ff_flag2_strict_gop",AV_CODEC_FLAG2_STRICT_GOP);
+#endif

 #if LIBAVCODEC_VERSION_MAJOR >= 54
   PARAM_DICT_FLAG("ff_flag_h263p_aiv", "aiv");
   PARAM_DICT_FLAG("ff_flag_obmc","obmc");
   PARAM_DICT_FLAG("ff_flag_h263p_slice_struct","structured_slices");
 #else
-  PARAM_FLAG("ff_flag_h263p_aiv",CODEC_FLAG_H263P_AIV);
-  PARAM_FLAG("ff_flag_obmc",CODEC_FLAG_OBMC);
-  PARAM_FLAG("ff_flag_h263p_slice_struct",CODEC_FLAG_H263P_SLICE_STRUCT);
+  PARAM_FLAG("ff_flag_h263p_aiv",AV_CODEC_FLAG_H263P_AIV);
+  PARAM_FLAG("ff_flag_obmc",AV_CODEC_FLAG_OBMC);
+  PARAM_FLAG("ff_flag_h263p_slice_struct",AV_CODEC_FLAG_H263P_SLICE_STRUCT);
 #endif

-  PARAM_FLAG("ff_flag_loop_filter",CODEC_FLAG_LOOP_FILTER);
-  PARAM_FLAG("ff_flag_closed_gop",CODEC_FLAG_CLOSED_GOP);
-  PARAM_FLAG2("ff_flag2_fast",CODEC_FLAG2_FAST);
-  PARAM_FLAG2("ff_flag2_strict_gop",CODEC_FLAG2_STRICT_GOP);
-  PARAM_ENUM("ff_coder_type",coder_type,coder_type);
+  PARAM_FLAG("ff_flag_loop_filter",AV_CODEC_FLAG_LOOP_FILTER);
+  PARAM_FLAG("ff_flag_closed_gop",AV_CODEC_FLAG_CLOSED_GOP);
+  PARAM_FLAG2("ff_flag2_fast",AV_CODEC_FLAG2_FAST);
+  PARAM_DICT_INT("ff_coder_type","coder");

   }
diff -Naur a/plugins/ffmpeg/params.h b/plugins/ffmpeg/params.h
--- a/plugins/ffmpeg/params.h	2011-05-11 16:13:39.000000000 +0100
+++ b/plugins/ffmpeg/params.h	2018-05-11 23:11:59.803990160 +0100
@@ -149,7 +149,7 @@
     .type =        LQT_PARAMETER_INT, \
     .val_default = { .val_int = 0 }, \
     .val_min =     { .val_int = 0 }, \
-    .val_max =     { .val_int = FF_MAX_B_FRAMES }, \
+    .val_max =     { .val_int = 16 }, \
     .help_string = TRS("Maximum number of B-frames between non B-frames") \
   }

diff -Naur a/plugins/ffmpeg/video.c b/plugins/ffmpeg/video.c
--- a/plugins/ffmpeg/video.c	2012-02-25 19:46:56.000000000 +0000
+++ b/plugins/ffmpeg/video.c	2018-05-11 23:15:15.697985432 +0100
@@ -37,10 +37,10 @@
 #endif

-#ifdef  PIX_FMT_YUV422P10
-#define PIX_FMT_YUV422P10_OR_DUMMY PIX_FMT_YUV422P10
+#ifdef  AV_PIX_FMT_YUV422P10
+#define AV_PIX_FMT_YUV422P10_OR_DUMMY AV_PIX_FMT_YUV422P10
 #else
-#define PIX_FMT_YUV422P10_OR_DUMMY -1234
+#define AV_PIX_FMT_YUV422P10_OR_DUMMY -1234
 #endif

 #if LIBAVCODEC_VERSION_INT >= ((54<<16)|(1<<8)|0)
@@ -90,9 +90,9 @@
   int imx_bitrate;
   int imx_strip_vbi;

-  /* In some cases FFMpeg would report something like PIX_FMT_YUV422P, while
-     we would like to treat it as PIX_FMT_YUVJ422P. It's only used for decoding */
-  enum PixelFormat reinterpret_pix_fmt;
+  /* In some cases FFMpeg would report something like AV_PIX_FMT_YUV422P, while
+     we would like to treat it as AV_PIX_FMT_YUVJ422P. It's only used for decoding */
+  enum AVPixelFormat reinterpret_pix_fmt;

   int is_imx;
   int y_offset;
@@ -137,42 +137,42 @@

 static const struct
   {
-  enum PixelFormat ffmpeg_id;
+  enum AVPixelFormat ffmpeg_id;
   int              lqt_id;
   int              exact;
   }
 colormodels[] =
   {
-    { PIX_FMT_YUV420P,   BC_YUV420P,   1 }, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
+    { AV_PIX_FMT_YUV420P,   BC_YUV420P,   1 }, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
 #if LIBAVUTIL_VERSION_INT < (50<<16)
-    { PIX_FMT_YUV422,    BC_YUV422,    1 },
+    { AV_PIX_FMT_YUV422,    BC_YUV422,    1 },
 #else
-    { PIX_FMT_YUYV422,   BC_YUV422,    1 },
+    { AV_PIX_FMT_YUYV422,   BC_YUV422,    1 },
 #endif
-    { PIX_FMT_RGB24,     BC_RGB888,    1 }, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
-    { PIX_FMT_BGR24,     BC_BGR888,    1 }, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
-    { PIX_FMT_YUV422P,   BC_YUV422P,   1 }, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
-    { PIX_FMT_YUV444P,   BC_YUV444P,   1 }, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
-    { PIX_FMT_YUV411P,   BC_YUV411P,   1 }, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
-    { PIX_FMT_YUV422P16, BC_YUV422P16, 1 }, ///< Planar 16 bit YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
-#ifdef PIX_FMT_YUV422P10
-    { PIX_FMT_YUV422P10, BC_YUV422P10, 1 }, ///< 10 bit samples in uint16_t containers, planar 4:2:2
-#endif
-    { PIX_FMT_RGB565,    BC_RGB565,    1 }, ///< always stored in cpu endianness
-    { PIX_FMT_YUVJ420P,  BC_YUVJ420P,  1 }, ///< Planar YUV 4:2:0 full scale (jpeg)
-    { PIX_FMT_YUVJ422P,  BC_YUVJ422P,  1 }, ///< Planar YUV 4:2:2 full scale (jpeg)
-    { PIX_FMT_YUVJ444P,  BC_YUVJ444P,  1 }, ///< Planar YUV 4:4:4 full scale (jpeg)
+    { AV_PIX_FMT_RGB24,     BC_RGB888,    1 }, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
+    { AV_PIX_FMT_BGR24,     BC_BGR888,    1 }, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
+    { AV_PIX_FMT_YUV422P,   BC_YUV422P,   1 }, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
+    { AV_PIX_FMT_YUV444P,   BC_YUV444P,   1 }, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
+    { AV_PIX_FMT_YUV411P,   BC_YUV411P,   1 }, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
+    { AV_PIX_FMT_YUV422P16, BC_YUV422P16, 1 }, ///< Planar 16 bit YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
+#ifdef AV_PIX_FMT_YUV422P10
+    { AV_PIX_FMT_YUV422P10, BC_YUV422P10, 1 }, ///< 10 bit samples in uint16_t containers, planar 4:2:2
+#endif
+    { AV_PIX_FMT_RGB565,    BC_RGB565,    1 }, ///< always stored in cpu endianness
+    { AV_PIX_FMT_YUVJ420P,  BC_YUVJ420P,  1 }, ///< Planar YUV 4:2:0 full scale (jpeg)
+    { AV_PIX_FMT_YUVJ422P,  BC_YUVJ422P,  1 }, ///< Planar YUV 4:2:2 full scale (jpeg)
+    { AV_PIX_FMT_YUVJ444P,  BC_YUVJ444P,  1 }, ///< Planar YUV 4:4:4 full scale (jpeg)
 #if LIBAVUTIL_VERSION_INT < (50<<16)
-    { PIX_FMT_RGBA32,    BC_RGBA8888,  0 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
+    { AV_PIX_FMT_RGBA32,    BC_RGBA8888,  0 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
 #else
-    { PIX_FMT_RGB32,     BC_RGBA8888,  0 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
+    { AV_PIX_FMT_RGB32,     BC_RGBA8888,  0 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
 #endif
-    { PIX_FMT_RGB555,    BC_RGB888,    0 }, ///< always stored in cpu endianness, most significant bit to 1
-    { PIX_FMT_GRAY8,     BC_RGB888,    0 },
-    { PIX_FMT_MONOWHITE, BC_RGB888,    0 }, ///< 0 is white
-    { PIX_FMT_MONOBLACK, BC_RGB888,    0 }, ///< 0 is black
-    { PIX_FMT_PAL8,      BC_RGB888,    0 }, ///< 8 bit with RGBA palette
-    { PIX_FMT_YUV410P,   BC_YUV420P,   0 }, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
+    { AV_PIX_FMT_RGB555,    BC_RGB888,    0 }, ///< always stored in cpu endianness, most significant bit to 1
+    { AV_PIX_FMT_GRAY8,     BC_RGB888,    0 },
+    { AV_PIX_FMT_MONOWHITE, BC_RGB888,    0 }, ///< 0 is white
+    { AV_PIX_FMT_MONOBLACK, BC_RGB888,    0 }, ///< 0 is black
+    { AV_PIX_FMT_PAL8,      BC_RGB888,    0 }, ///< 8 bit with RGBA palette
+    { AV_PIX_FMT_YUV410P,   BC_YUV420P,   0 }, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
   };

 static const struct
@@ -343,16 +343,16 @@
   if (!codec->pix_fmts)
     return 0;

-  for (i = 0; codec->pix_fmts[i] != PIX_FMT_NONE; ++i)
+  for (i = 0; codec->pix_fmts[i] != AV_PIX_FMT_NONE; ++i)
     {
-    if (codec->pix_fmts[i] == PIX_FMT_YUV422P10_OR_DUMMY)
+    if (codec->pix_fmts[i] == AV_PIX_FMT_YUV422P10_OR_DUMMY)
       return 1;
     }

   return 0;
   }

-static enum PixelFormat lqt_ffmpeg_get_ffmpeg_colormodel(int id)
+static enum AVPixelFormat lqt_ffmpeg_get_ffmpeg_colormodel(int id)
   {
   int i;

@@ -361,10 +361,10 @@
     if(colormodels[i].lqt_id == id)
       return colormodels[i].ffmpeg_id;
     }
-  return PIX_FMT_NB;
+  return AV_PIX_FMT_NB;
   }

-static int lqt_ffmpeg_get_lqt_colormodel(enum PixelFormat id, int * exact)
+static int lqt_ffmpeg_get_lqt_colormodel(enum AVPixelFormat id, int * exact)
   {
   int i;

@@ -400,26 +400,26 @@
   codec->reinterpret_pix_fmt = codec->avctx->pix_fmt;

   /* First we try codec-specific colormodel matching. */
-  if(codec->decoder->id == CODEC_ID_DNXHD)
+  if(codec->decoder->id == AV_CODEC_ID_DNXHD)
     {
-    /* FFMpeg supports PIX_FMT_YUV422P and PIX_FMT_YUV422P10 for DNxHD, which
-       we sometimes interpret as PIX_FMT_YUVJ422P and PIX_FMT_YUVJ422P10. */
-    if (codec->avctx->pix_fmt == PIX_FMT_YUV422P || codec->avctx->pix_fmt == PIX_FMT_YUV422P10_OR_DUMMY)
+    /* FFMpeg supports AV_PIX_FMT_YUV422P and AV_PIX_FMT_YUV422P10 for DNxHD, which
+       we sometimes interpret as AV_PIX_FMT_YUVJ422P and AV_PIX_FMT_YUVJ422P10. */
+    if (codec->avctx->pix_fmt == AV_PIX_FMT_YUV422P || codec->avctx->pix_fmt == AV_PIX_FMT_YUV422P10_OR_DUMMY)
       {
-      int p10 = (codec->avctx->pix_fmt == PIX_FMT_YUV422P10_OR_DUMMY);
+      int p10 = (codec->avctx->pix_fmt == AV_PIX_FMT_YUV422P10_OR_DUMMY);
       *exact = 1;
       if (lqt_ffmpeg_get_avid_yuv_range(vtrack->track) == AVID_FULL_YUV_RANGE)
         {
         vtrack->stream_cmodel = p10 ? BC_YUVJ422P10 : BC_YUVJ422P;
-        codec->reinterpret_pix_fmt = p10 ? PIX_FMT_YUV422P10_OR_DUMMY : PIX_FMT_YUVJ422P;
-        // Note: reinterpret_pix_fmt should really be PIX_FMT_YUVJ422P10, except
+        codec->reinterpret_pix_fmt = p10 ? AV_PIX_FMT_YUV422P10_OR_DUMMY : AV_PIX_FMT_YUVJ422P;
+        // Note: reinterpret_pix_fmt should really be AV_PIX_FMT_YUVJ422P10, except
         // there is no such colormodel in FFMpeg. Fortunately, it's not a problem
         // in this case, as reinterpret_pix_fmt is only used when *exact == 0.
         }
       else
         {
         vtrack->stream_cmodel = p10 ? BC_YUV422P10 : BC_YUV422P;
-        codec->reinterpret_pix_fmt = p10 ? PIX_FMT_YUV422P10_OR_DUMMY : PIX_FMT_YUV422P;
+        codec->reinterpret_pix_fmt = p10 ? AV_PIX_FMT_YUV422P10_OR_DUMMY : AV_PIX_FMT_YUV422P;
         }
       return;
       }
@@ -438,16 +438,16 @@
   quicktime_ffmpeg_video_codec_t *codec = vtrack->codec->priv;
   codec->avctx->pix_fmt = lqt_ffmpeg_get_ffmpeg_colormodel(vtrack->stream_cmodel);

-  if (codec->encoder->id == CODEC_ID_DNXHD)
+  if (codec->encoder->id == AV_CODEC_ID_DNXHD)
     {
-    /* FFMpeg's DNxHD encoder only supports PIX_FMT_YUV422P and PIX_FMT_YUV422P10
-       and doesn't know anything about PIX_FMT_YUVJ422P and PIX_FMT_YUVJ422P10
+    /* FFMpeg's DNxHD encoder only supports AV_PIX_FMT_YUV422P and AV_PIX_FMT_YUV422P10
+       and doesn't know anything about AV_PIX_FMT_YUVJ422P and AV_PIX_FMT_YUVJ422P10
        (in fact, the latter doesn't even exist) */
-    codec->avctx->pix_fmt = PIX_FMT_YUV422P;
+    codec->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
     if (vtrack->stream_cmodel == BC_YUV422P10 || vtrack->stream_cmodel == BC_YUVJ422P10)
       {
       if (lqt_tenbit_dnxhd_supported(codec->encoder))
-        codec->avctx->pix_fmt = PIX_FMT_YUV422P10_OR_DUMMY;
+        codec->avctx->pix_fmt = AV_PIX_FMT_YUV422P10_OR_DUMMY;
       }
     }
   }
@@ -458,7 +458,7 @@
 /* From avcodec.h: */

 /*
- * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
+ * AV_PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
  * color is put together as:
  *  (A << 24) | (R << 16) | (G << 8) | B
  * This is stored as BGRA on little endian CPU architectures and ARGB on
@@ -530,7 +530,7 @@
  */

 static void convert_image_decode(quicktime_ffmpeg_video_codec_t *codec,
-                                 AVFrame * in_frame, enum PixelFormat in_format,
+                                 AVFrame * in_frame, enum AVPixelFormat in_format,
                                  unsigned char ** out_frame, int out_format,
                                  int width, int height, int row_span, int row_span_uv)
   {
@@ -547,9 +547,9 @@
    *  RGBA format like in ffmpeg??
    */
 #if LIBAVUTIL_VERSION_INT < (50<<16)
-  if((in_format == PIX_FMT_RGBA32) && (out_format == BC_RGBA8888))
+  if((in_format == AV_PIX_FMT_RGBA32) && (out_format == BC_RGBA8888))
 #else
-    if((in_format == PIX_FMT_RGB32) && (out_format == BC_RGBA8888))
+    if((in_format == AV_PIX_FMT_RGB32) && (out_format == BC_RGBA8888))
 #endif
       {
       convert_image_decode_rgba(in_frame, out_frame, width, height, codec->y_offset);
@@ -728,13 +728,13 @@

     /* Set extradata: It's done differently for each codec */

-    if(codec->decoder->id == CODEC_ID_SVQ3)
+    if(codec->decoder->id == AV_CODEC_ID_SVQ3)
       {
       extradata       = trak->mdia.minf.stbl.stsd.table[0].table_raw + 4;
       extradata_size  = trak->mdia.minf.stbl.stsd.table[0].table_raw_size - 4;

       }
-    else if(codec->decoder->id == CODEC_ID_H264)
+    else if(codec->decoder->id == AV_CODEC_ID_H264)
       {
       user_atom = quicktime_stsd_get_user_atom(trak, "avcC", &user_atom_len);

@@ -753,7 +753,7 @@
         }

       }
-    else if(codec->decoder->id == CODEC_ID_MPEG4)
+    else if(codec->decoder->id == AV_CODEC_ID_MPEG4)
       {
       if(trak->mdia.minf.stbl.stsd.table[0].has_esds)
         {
@@ -781,7 +781,7 @@
     if(extradata)
       {
       codec->extradata =
-        calloc(1, extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+        calloc(1, extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
       memcpy(codec->extradata, extradata, extradata_size);
       codec->avctx->extradata_size = extradata_size;
       codec->avctx->extradata = codec->extradata;
@@ -829,7 +829,7 @@
     if(avcodec_open2(codec->avctx, codec->decoder, NULL) != 0)
       return -1;
 #endif
-    codec->frame = avcodec_alloc_frame();
+    codec->frame = av_frame_alloc();
     vtrack->stream_cmodel = LQT_COLORMODEL_NONE;
     codec->initialized = 1;
     }
@@ -929,10 +929,10 @@
 #ifdef HAVE_LIBSWSCALE

 #if LIBAVUTIL_VERSION_INT < (50<<16)
-      if(!((codec->avctx->pix_fmt == PIX_FMT_RGBA32) &&
+      if(!((codec->avctx->pix_fmt == AV_PIX_FMT_RGBA32) &&
            (vtrack->stream_cmodel == BC_RGBA8888)))
 #else
-        if(!((codec->avctx->pix_fmt == PIX_FMT_RGB32) &&
+        if(!((codec->avctx->pix_fmt == AV_PIX_FMT_RGB32) &&
              (vtrack->stream_cmodel == BC_RGBA8888)))
 #endif
           {
@@ -947,15 +947,15 @@
           }
 #endif
       }
-    if(codec->decoder->id == CODEC_ID_DVVIDEO)
+    if(codec->decoder->id == AV_CODEC_ID_DVVIDEO)
       {
       if(vtrack->stream_cmodel == BC_YUV420P)
         vtrack->chroma_placement = LQT_CHROMA_PLACEMENT_DVPAL;
       vtrack->interlace_mode = LQT_INTERLACE_BOTTOM_FIRST;
       vtrack->ci.id = LQT_COMPRESSION_DV;
       }
-    else if((codec->decoder->id == CODEC_ID_MPEG4) ||
-            (codec->decoder->id == CODEC_ID_H264))
+    else if((codec->decoder->id == AV_CODEC_ID_MPEG4) ||
+            (codec->decoder->id == AV_CODEC_ID_H264))
       {
       if(vtrack->stream_cmodel == BC_YUV420P)
         vtrack->chroma_placement = LQT_CHROMA_PLACEMENT_MPEG2;
@@ -1140,8 +1140,8 @@
   codec->avctx->qmin = 1;
   codec->avctx->qmax = 3;
   codec->avctx->rtp_payload_size = 1; // ??
-  codec->avctx->rc_buffer_aggressivity = 0.25;
-  codec->avctx->flags |= CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_LOW_DELAY;
+  av_dict_set(&codec->options, "rc_buf_aggressivity", "0.25", 0);
+  codec->avctx->flags |= AV_CODEC_FLAG_INTERLACED_DCT|AV_CODEC_FLAG_LOW_DELAY;

 #if (LIBAVCODEC_VERSION_MAJOR < 54)
   codec->avctx->flags2 |= CODEC_FLAG2_INTRA_VLC|CODEC_FLAG2_NON_LINEAR_QUANT;
@@ -1299,13 +1299,13 @@
     {
     if(vtrack->stream_cmodel == BC_YUV420P)
       {
-      if(codec->encoder->id == CODEC_ID_MPEG4)
+      if(codec->encoder->id == AV_CODEC_ID_MPEG4)
         {
         vtrack->chroma_placement = LQT_CHROMA_PLACEMENT_MPEG2;
         /* enable interlaced encoding */
         vtrack->interlace_mode = LQT_INTERLACE_NONE;
         }
-      else if(codec->encoder->id == CODEC_ID_DVVIDEO)
+      else if(codec->encoder->id == AV_CODEC_ID_DVVIDEO)
         {
         vtrack->chroma_placement = LQT_CHROMA_PLACEMENT_DVPAL;
         }
@@ -1318,7 +1318,7 @@

   if(!codec->initialized)
     {
-    codec->frame = avcodec_alloc_frame();
+    codec->frame = av_frame_alloc();

     /* time_base is 1/framerate for constant framerate */

@@ -1328,7 +1328,7 @@
     //          codec->avctx->time_base.den = 1;
     //          codec->avctx->time_base.num = lqt_video_time_scale(file, track);

-    if(codec->avctx->flags & CODEC_FLAG_QSCALE)
+    if(codec->avctx->flags & AV_CODEC_FLAG_QSCALE)
       codec->avctx->global_quality = codec->qscale;

     codec->avctx->width = width;
@@ -1340,11 +1340,11 @@
     codec->avctx->sample_aspect_ratio.num = pixel_width;
     codec->avctx->sample_aspect_ratio.den = pixel_height;
     /* Use global headers for mp4v */
-    if(codec->encoder->id == CODEC_ID_MPEG4)
+    if(codec->encoder->id == AV_CODEC_ID_MPEG4)
       {
       if(!(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)))
         {
-        codec->avctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
+        codec->avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
         codec->write_global_header = 1;
         }

@@ -1360,16 +1360,16 @@
         {
         lqt_log(file, LQT_LOG_INFO, LOG_DOMAIN, "Enabling interlaced encoding");
         codec->avctx->flags |=
-          (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME|CODEC_FLAG_ALT_SCAN);
+          (AV_CODEC_FLAG_INTERLACED_DCT|AV_CODEC_FLAG_INTERLACED_ME|AV_CODEC_FLAG_ALT_SCAN);
         }
 #endif
       }
-    else if((codec->encoder->id == CODEC_ID_MSMPEG4V3) && (trak->strl) &&
+    else if((codec->encoder->id == AV_CODEC_ID_MSMPEG4V3) && (trak->strl) &&
             !strncmp(trak->strl->strf.bh.biCompression, "DIV3", 4))
       {
       strncpy(trak->strl->strh.fccHandler, "div3", 4);
       }
-    else if((codec->encoder->id == CODEC_ID_H263) &&
+    else if((codec->encoder->id == AV_CODEC_ID_H263) &&
             (file->file_type & (LQT_FILE_MP4|LQT_FILE_3GP)))
       {
       uint8_t d263_data[] =
@@ -1383,34 +1383,34 @@
       strncpy(trak->mdia.minf.stbl.stsd.table[0].format,
               "s263", 4);
       }
-    else if(codec->encoder->id == CODEC_ID_FFVHUFF)
+    else if(codec->encoder->id == AV_CODEC_ID_FFVHUFF)
       {
       if(!(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)))
         {
-        codec->avctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
+        codec->avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
         codec->write_global_header = 1;
         }
       }
-    else if(codec->encoder->id == CODEC_ID_QTRLE)
+    else if(codec->encoder->id == AV_CODEC_ID_QTRLE)
       {
       if(vtrack->stream_cmodel == BC_RGBA8888)
         {
         /* Libquicktime doesn't natively support a color model equivalent
-           to PIX_FMT_ARGB, which is required for QTRLE with alpha channel.
+           to AV_PIX_FMT_ARGB, which is required for QTRLE with alpha channel.
            So, we use BC_RGBA8888 and do ad hoc conversion below. */
-        codec->avctx->pix_fmt = PIX_FMT_ARGB;
+        codec->avctx->pix_fmt = AV_PIX_FMT_ARGB;
         vtrack->track->mdia.minf.stbl.stsd.table[0].depth = 32;
         }
       }
-    else if(codec->encoder->id == CODEC_ID_DVVIDEO)
+    else if(codec->encoder->id == AV_CODEC_ID_DVVIDEO)
       {
       set_dv_fourcc(width, height, vtrack->stream_cmodel, trak);
       }
-    else if(codec->encoder->id == CODEC_ID_DNXHD)
+    else if(codec->encoder->id == AV_CODEC_ID_DNXHD)
       {
       if(vtrack->interlace_mode != LQT_INTERLACE_NONE)
         {
-        codec->avctx->flags |= CODEC_FLAG_INTERLACED_DCT;
+        codec->avctx->flags |= AV_CODEC_FLAG_INTERLACED_DCT;
         }
       }
     else if(codec->is_imx)
@@ -1422,7 +1422,7 @@
       if(codec->pass == 1)
         {
         codec->stats_file = fopen(codec->stats_filename, "w");
-        codec->avctx->flags |= CODEC_FLAG_PASS1;
+        codec->avctx->flags |= AV_CODEC_FLAG_PASS1;
         }
       else if(codec->pass == codec->total_passes)
         {
@@ -1438,7 +1438,7 @@
         fclose(codec->stats_file);
         codec->stats_file = (FILE*)0;

-        codec->avctx->flags |= CODEC_FLAG_PASS2;
+        codec->avctx->flags |= AV_CODEC_FLAG_PASS2;
         }
       }
     /* Open codec */
@@ -1467,7 +1467,7 @@
     }
   //        codec->lqt_colormodel = ffmepg_2_lqt(codec->com.ffcodec_enc);

-  if(codec->y_offset != 0 || codec->avctx->pix_fmt == PIX_FMT_ARGB)
+  if(codec->y_offset != 0 || codec->avctx->pix_fmt == AV_PIX_FMT_ARGB)
     {
     if(!codec->tmp_rows)
       {
@@ -1492,7 +1492,7 @@
                         vtrack->stream_cmodel,
                         0, 0, 0, codec->y_offset);
       }
-    else if(codec->avctx->pix_fmt == PIX_FMT_ARGB)
+    else if(codec->avctx->pix_fmt == AV_PIX_FMT_ARGB)
       {
       convert_rgba_to_argb(row_pointers[0], vtrack->stream_row_span,
                            codec->tmp_rows[0], codec->tmp_row_span,
@@ -1516,7 +1516,7 @@
     }

   codec->frame->pts = vtrack->timestamp;
-  if(codec->avctx->flags & CODEC_FLAG_QSCALE)
+  if(codec->avctx->flags & AV_CODEC_FLAG_QSCALE)
     codec->frame->quality = codec->qscale;
 #ifdef DO_INTERLACE
   if(vtrack->interlace_mode != LQT_INTERLACE_NONE)
@@ -1558,12 +1558,12 @@

 #endif

-  if(!was_initialized && codec->encoder->id == CODEC_ID_DNXHD)
+  if(!was_initialized && codec->encoder->id == AV_CODEC_ID_DNXHD)
     setup_avid_atoms(file, vtrack, codec->buffer, bytes_encoded);

   if(bytes_encoded)
     {
-    if (pts == AV_NOPTS_VALUE || (codec->encoder->id == CODEC_ID_DNXHD && pts == 0))
+    if (pts == AV_NOPTS_VALUE || (codec->encoder->id == AV_CODEC_ID_DNXHD && pts == 0))
       {
       /* Some codecs don't bother generating presentation timestamps.
          FFMpeg's DNxHD encoder doesn't even bother to set it to AV_NOPTS_VALUE. */
@@ -1590,17 +1590,16 @@

   if(codec->write_global_header && !codec->global_header_written)
     {
-    if(codec->encoder->id == CODEC_ID_FFVHUFF)
+    if(codec->encoder->id == AV_CODEC_ID_FFVHUFF)
       {
       quicktime_user_atoms_add_atom(&trak->mdia.minf.stbl.stsd.table[0].user_atoms,
                                     "glbl",
                                     codec->avctx->extradata, codec->avctx->extradata_size );
       }
-    else if(codec->encoder->id == CODEC_ID_MPEG4)
+    else if(codec->encoder->id == AV_CODEC_ID_MPEG4)
       {
       int advanced = 0;
-      if(codec->avctx->max_b_frames ||
-         (codec->avctx->flags & (CODEC_FLAG_QPEL|CODEC_FLAG_GMC)))
+      if(codec->avctx->max_b_frames)
         advanced = 1;

       setup_header_mpeg4(file, track, codec->avctx->extradata,
@@ -1903,18 +1902,18 @@
     codec_base->encode_video = lqt_ffmpeg_encode_video;
     codec_base->set_pass = set_pass_ffmpeg;

-    if(encoder->id == CODEC_ID_MPEG4)
+    if(encoder->id == AV_CODEC_ID_MPEG4)
       {
       codec_base->writes_compressed = writes_compressed_mpeg4;
       codec_base->init_compressed   = init_compressed_mpeg4;
       codec_base->write_packet = write_packet_mpeg4;
       }
-    else if(encoder->id == CODEC_ID_MPEG2VIDEO)
+    else if(encoder->id == AV_CODEC_ID_MPEG2VIDEO)
       {
       codec_base->writes_compressed = writes_compressed_imx;
       codec_base->init_compressed   = init_compressed_imx;
       }
-    else if(encoder->id == CODEC_ID_DVVIDEO)
+    else if(encoder->id == AV_CODEC_ID_DVVIDEO)
       {
       codec_base->init_compressed = init_compressed_dv;
       }
@@ -1922,7 +1921,7 @@
     }
   if(decoder)
     {
-    if(decoder->id == CODEC_ID_H264)
+    if(decoder->id == AV_CODEC_ID_H264)
       codec_base->read_packet = read_packet_h264;
     codec_base->decode_video = lqt_ffmpeg_decode_video;
     }
diff -Naur a/src/util.c b/src/util.c
--- a/src/util.c	2011-01-07 14:40:47.000000000 +0000
+++ b/src/util.c	2018-05-11 23:11:04.367991499 +0100
@@ -340,9 +340,14 @@

 void quicktime_read_pascal(quicktime_t *file, char *data)
 {
-	char len = quicktime_read_char(file);
-	quicktime_read_data(file, (uint8_t*)data, len);
-	data[(int)len] = 0;
+	int len = quicktime_read_char(file);
+	if ((len > 0) && (len < 256)) {
+          /* data[] is expected to be 256 bytes long */
+          quicktime_read_data(file, (uint8_t*)data, len);
+          data[len] = 0;
+        } else {
+          data[0] = 0;
+        }
 }

 void quicktime_write_pascal(quicktime_t *file, char *data)

license: mit


code:
Fix CVE-2017-12562:

https://github.com/erikd/libsndfile/issues/292
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-12562

Patch copied from upstream source repository:

https://github.com/erikd/libsndfile/commit/cf7a8182c2642c50f1cf90dddea9ce96a8bad2e8

From cf7a8182c2642c50f1cf90dddea9ce96a8bad2e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rn=20Heusipp?= <osmanx@problemloesungsmaschine.de>
Date: Wed, 14 Jun 2017 12:25:40 +0200
Subject: [PATCH] src/common.c: Fix heap buffer overflows when writing strings
 in binheader

Fixes the following problems:
 1. Case 's' only enlarges the buffer by 16 bytes instead of size bytes.
 2. psf_binheader_writef() enlarges the header buffer (if needed) prior to the
    big switch statement by an amount (16 bytes) which is enough for all cases
    where only a single value gets added. Cases 's', 'S', 'p' however
    additionally write an arbitrary length block of data and again enlarge the
    buffer to the required amount. However, the required space calculation does
    not take into account the size of the length field which gets output before
    the data.
 3. Buffer size requirement calculation in case 'S' does not account for the
    padding byte ("size += (size & 1) ;" happens after the calculation which
    uses "size").
 4. Case 'S' can overrun the header buffer by 1 byte when no padding is
    involved
    ("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;" while
    the buffer is only guaranteed to have "size" space available).
 5. "psf->header.ptr [psf->header.indx] = 0 ;" in case 'S' always writes 1 byte
    beyond the space which is guaranteed to be allocated in the header buffer.
 6. Case 's' can overrun the provided source string by 1 byte if padding is
    involved ("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;"
    where "size" is "strlen (strptr) + 1" (which includes the 0 terminator,
    plus optionally another 1 which is padding and not guaranteed to be
    readable via the source string pointer).

Closes: https://github.com/erikd/libsndfile/issues/292
---
 src/common.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/common.c b/src/common.c
index 1a6204ca..6b2a2ee9 100644
--- a/src/common.c
+++ b/src/common.c
@@ -681,16 +681,16 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
 					/* Write a C string (guaranteed to have a zero terminator). */
 					strptr = va_arg (argptr, char *) ;
 					size = strlen (strptr) + 1 ;
-					size += (size & 1) ;

-					if (psf->header.indx + (sf_count_t) size >= psf->header.len && psf_bump_header_allocation (psf, 16))
+					if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
 						return count ;

 					if (psf->rwf_endian == SF_ENDIAN_BIG)
-						header_put_be_int (psf, size) ;
+						header_put_be_int (psf, size + (size & 1)) ;
 					else
-						header_put_le_int (psf, size) ;
+						header_put_le_int (psf, size + (size & 1)) ;
 					memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
+					size += (size & 1) ;
 					psf->header.indx += size ;
 					psf->header.ptr [psf->header.indx - 1] = 0 ;
 					count += 4 + size ;
@@ -703,16 +703,15 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
 					*/
 					strptr = va_arg (argptr, char *) ;
 					size = strlen (strptr) ;
-					if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
+					if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
 						return count ;
 					if (psf->rwf_endian == SF_ENDIAN_BIG)
 						header_put_be_int (psf, size) ;
 					else
 						header_put_le_int (psf, size) ;
-					memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;
+					memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + (size & 1)) ;
 					size += (size & 1) ;
 					psf->header.indx += size ;
-					psf->header.ptr [psf->header.indx] = 0 ;
 					count += 4 + size ;
 					break ;

@@ -724,7 +723,7 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
 					size = (size & 1) ? size : size + 1 ;
 					size = (size > 254) ? 254 : size ;

-					if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
+					if (psf->header.indx + 1 + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, 1 + size))
 						return count ;

 					header_put_byte (psf, size) ;


code:
Fix CVE-2017-{8361,8363,8365}:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8361
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8363
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8365

Patch copied from upstream source repository:

https://github.com/erikd/libsndfile/commit/fd0484aba8e51d16af1e3a880f9b8b857b385eb3

From fd0484aba8e51d16af1e3a880f9b8b857b385eb3 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Wed, 12 Apr 2017 19:45:30 +1000
Subject: [PATCH] FLAC: Fix a buffer read overrun

Buffer read overrun occurs when reading a FLAC file that switches
from 2 channels to one channel mid-stream. Only option is to
abort the read.

Closes: https://github.com/erikd/libsndfile/issues/230
---
 src/common.h  |  1 +
 src/flac.c    | 13 +++++++++++++
 src/sndfile.c |  1 +
 3 files changed, 15 insertions(+)

diff --git a/src/common.h b/src/common.h
index 0bd810c3..e2669b6a 100644
--- a/src/common.h
+++ b/src/common.h
@@ -725,6 +725,7 @@ enum
 	SFE_FLAC_INIT_DECODER,
 	SFE_FLAC_LOST_SYNC,
 	SFE_FLAC_BAD_SAMPLE_RATE,
+	SFE_FLAC_CHANNEL_COUNT_CHANGED,
 	SFE_FLAC_UNKOWN_ERROR,

 	SFE_WVE_NOT_WVE,
diff --git a/src/flac.c b/src/flac.c
index 84de0e26..986a7b8f 100644
--- a/src/flac.c
+++ b/src/flac.c
@@ -434,6 +434,19 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_

 	switch (metadata->type)
 	{	case FLAC__METADATA_TYPE_STREAMINFO :
+			if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
+			{	psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
+									"Nothing to be but to error out.\n" ,
+									psf->sf.channels, metadata->data.stream_info.channels) ;
+				psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
+				return ;
+				} ;
+
+			if (psf->sf.channels > 0 && psf->sf.samplerate != (int) metadata->data.stream_info.sample_rate)
+			{	psf_log_printf (psf, "Warning: FLAC stream changed sample rates from %d to %d.\n"
+									"Carrying on as if nothing happened.",
+									psf->sf.samplerate, metadata->data.stream_info.sample_rate) ;
+				} ;
 			psf->sf.channels = metadata->data.stream_info.channels ;
 			psf->sf.samplerate = metadata->data.stream_info.sample_rate ;
 			psf->sf.frames = metadata->data.stream_info.total_samples ;
diff --git a/src/sndfile.c b/src/sndfile.c
index 41875610..e2a87be8 100644
--- a/src/sndfile.c
+++ b/src/sndfile.c
@@ -245,6 +245,7 @@ ErrorStruct SndfileErrors [] =
 	{	SFE_FLAC_INIT_DECODER	, "Error : problem with initialization of the flac decoder." },
 	{	SFE_FLAC_LOST_SYNC		, "Error : flac decoder lost sync." },
 	{	SFE_FLAC_BAD_SAMPLE_RATE, "Error : flac does not support this sample rate." },
+	{	SFE_FLAC_CHANNEL_COUNT_CHANGED, "Error : flac channel changed mid stream." },
 	{	SFE_FLAC_UNKOWN_ERROR	, "Error : unknown error in flac decoder." },

 	{	SFE_WVE_NOT_WVE			, "Error : not a WVE file." },
--
2.12.2


code:
Fix CVE-2017-8362:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8362

Patch copied from upstream source repository:

https://github.com/erikd/libsndfile/commit/ef1dbb2df1c0e741486646de40bd638a9c4cd808

From ef1dbb2df1c0e741486646de40bd638a9c4cd808 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Fri, 14 Apr 2017 15:19:16 +1000
Subject: [PATCH] src/flac.c: Fix a buffer read overflow

A file (generated by a fuzzer) which increased the number of channels
from one frame to the next could cause a read beyond the end of the
buffer provided by libFLAC. Only option is to abort the read.

Closes: https://github.com/erikd/libsndfile/issues/231
---
 src/flac.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/flac.c b/src/flac.c
index 5a4f8c21..e4f9aaa0 100644
--- a/src/flac.c
+++ b/src/flac.c
@@ -169,6 +169,14 @@ flac_buffer_copy (SF_PRIVATE *psf)
 	const int32_t* const *buffer = pflac->wbuffer ;
 	unsigned i = 0, j, offset, channels, len ;

+	if (psf->sf.channels != (int) frame->header.channels)
+	{	psf_log_printf (psf, "Error: FLAC frame changed from %d to %d channels\n"
+									"Nothing to do but to error out.\n" ,
+									psf->sf.channels, frame->header.channels) ;
+		psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
+		return 0 ;
+		} ;
+
 	/*
 	**	frame->header.blocksize is variable and we're using a constant blocksize
 	**	of FLAC__MAX_BLOCK_SIZE.
@@ -202,7 +210,6 @@ flac_buffer_copy (SF_PRIVATE *psf)
 		return 0 ;
 		} ;

-
 	len = SF_MIN (pflac->len, frame->header.blocksize) ;

 	if (pflac->remain % channels != 0)
@@ -436,7 +443,7 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
 	{	case FLAC__METADATA_TYPE_STREAMINFO :
 			if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
 			{	psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
-									"Nothing to be but to error out.\n" ,
+									"Nothing to do but to error out.\n" ,
 									psf->sf.channels, metadata->data.stream_info.channels) ;
 				psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
 				return ;
--
2.12.2


code:
This is a regression in 1.0.28 that causes a test failure on armhf.

Upstream bug URL:

https://github.com/erikd/libsndfile/issues/229

Patch copied from upstream source repository:

https://github.com/erikd/libsndfile/commit/9d470ee5577d3ccedb1c28c7e0a7295ba17feaf5

From 9d470ee5577d3ccedb1c28c7e0a7295ba17feaf5 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Sun, 16 Apr 2017 17:54:17 +1000
Subject: [PATCH] src/rf64.c: Fix varargs related bug

C's <stargs.h> functionality isn't type checked so that passing an
`sf_count_t` (64 bits) by mistake in place of a `unit32_t` can cause
errors. This would be fine if it was an error on every architecture
and platform, but its not. This particular problem only manifested
on armhf and some other Arm architectures. It was not an issue on
32 bit x86.

I have now fixed variants of this same bug several times.

Closes: https://github.com/erikd/libsndfile/issues/229
---
 src/rf64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rf64.c b/src/rf64.c
index b3d637f..02dd904 100644
--- a/src/rf64.c
+++ b/src/rf64.c
@@ -742,7 +742,7 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length)

 	pad_size = psf->dataoffset - 16 - psf->header.indx ;
 	if (pad_size >= 0)
-		psf_binheader_writef (psf, "m4z", PAD_MARKER, pad_size, make_size_t (pad_size)) ;
+		psf_binheader_writef (psf, "m4z", PAD_MARKER, (unsigned int) pad_size, make_size_t (pad_size)) ;

 	if (wpriv->rf64_downgrade && (psf->filelength < RIFF_DOWNGRADE_BYTES))
 		psf_binheader_writef (psf, "tm8", data_MARKER, psf->datalength) ;


code:
Author: Raphael Geissert <geissert@debian.org>
Bug-Debian: https://bugs.debian.org/731860
Description: Avoid directory traversal when extracting archives
 by skipping over leading slashes and any prefix containing ".." components.
Forwarded: yes

--- a/lib/decode.c
+++ b/lib/decode.c
@@ -22,6 +22,36 @@
 #endif

+char *
+safer_name_suffix (char const *file_name)
+{
+	char const *p, *t;
+	p = t = file_name;
+	while (*p == '/') t = ++p;
+	while (*p)
+	{
+		while (p[0] == '.' && p[0] == p[1] && p[2] == '/')
+		{
+			p += 3;
+			t = p;
+		}
+		/* advance pointer past the next slash */
+		while (*p && (p++)[0] != '/');
+	}
+
+	if (!*t)
+	{
+		t = ".";
+	}
+
+	if (t != file_name)
+	{
+		/* TODO: warn somehow that the path was modified */
+	}
+	return (char*)t;
+}
+
+
 /* determine full path name */
 char *
 th_get_pathname(TAR *t)
@@ -29,17 +59,17 @@ th_get_pathname(TAR *t)
 	static char filename[MAXPATHLEN];

 	if (t->th_buf.gnu_longname)
-		return t->th_buf.gnu_longname;
+		return safer_name_suffix(t->th_buf.gnu_longname);

 	if (t->th_buf.prefix[0] != '\0')
 	{
 		snprintf(filename, sizeof(filename), "%.155s/%.100s",
 			 t->th_buf.prefix, t->th_buf.name);
-		return filename;
+		return safer_name_suffix(filename);
 	}

 	snprintf(filename, sizeof(filename), "%.100s", t->th_buf.name);
-	return filename;
+	return safer_name_suffix(filename);
 }

--- a/lib/extract.c
+++ b/lib/extract.c
@@ -298,14 +298,14 @@ tar_extract_hardlink(TAR * t, char *real
 	if (mkdirhier(dirname(filename)) == -1)
 		return -1;
 	libtar_hashptr_reset(&hp);
-	if (libtar_hash_getkey(t->h, &hp, th_get_linkname(t),
+	if (libtar_hash_getkey(t->h, &hp, safer_name_suffix(th_get_linkname(t)),
 			       (libtar_matchfunc_t)libtar_str_match) != 0)
 	{
 		lnp = (char *)libtar_hashptr_data(&hp);
 		linktgt = &lnp[strlen(lnp) + 1];
 	}
 	else
-		linktgt = th_get_linkname(t);
+		linktgt = safer_name_suffix(th_get_linkname(t));

 #ifdef DEBUG
 	printf("  ==> extracting: %s (link to %s)\n", filename, linktgt);
@@ -343,9 +343,9 @@ tar_extract_symlink(TAR *t, char *realna

 #ifdef DEBUG
 	printf("  ==> extracting: %s (symlink to %s)\n",
-	       filename, th_get_linkname(t));
+	       filename, safer_name_suffix(th_get_linkname(t)));
 #endif
-	if (symlink(th_get_linkname(t), filename) == -1)
+	if (symlink(safer_name_suffix(th_get_linkname(t)), filename) == -1)
 	{
 #ifdef DEBUG
 		perror("symlink()");
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -15,3 +15,4 @@

 #include <libtar.h>

+char* safer_name_suffix(char const*);
--- a/lib/output.c
+++ b/lib/output.c
@@ -123,9 +123,9 @@ th_print_long_ls(TAR *t)
 		else
 			printf(" link to ");
 		if ((t->options & TAR_GNU) && t->th_buf.gnu_longlink != NULL)
-			printf("%s", t->th_buf.gnu_longlink);
+			printf("%s", safer_name_suffix(t->th_buf.gnu_longlink));
 		else
-			printf("%.100s", t->th_buf.linkname);
+			printf("%.100s", safer_name_suffix(t->th_buf.linkname));
 	}

 	putchar('\n');


code:
Copied from Debian.

Description: Disable SSE2 code on i386
 This patch is not complete. A high-graded solution may use automatic switching
 between SSE2 and C++ implementations based on the results of runtime checks.
 The webrtc code already provides for one of them inside its GetCPUInfo function.
Bug-Debian: https://bugs.debian.org/892823
Author: Nicholas Guriev <guriev-ns@ya.ru>
Last-Update: Tue, 29 Jan 2019 23:26:38 +0300

--- a/libtgvoip.gyp
+++ b/libtgvoip.gyp
@@ -871,11 +871,7 @@
                 'WEBRTC_POSIX',
               ],
               'conditions': [
-                [ '"<!(uname -m)" == "i686"', {
-                  'cflags_cc': [
-                    '-msse2',
-                  ],
-                }], ['"<!(uname -s)" == "Linux"', {
+                [ '"<!(uname -s)" == "Linux"', {
                   'defines': [
                     'WEBRTC_LINUX',
                   ],
--- a/webrtc_dsp/rtc_base/system/arch.h
+++ b/webrtc_dsp/rtc_base/system/arch.h
@@ -28,7 +28,10 @@
 #define WEBRTC_ARCH_64_BITS
 #define WEBRTC_ARCH_LITTLE_ENDIAN
 #elif defined(_M_IX86) || defined(__i386__)
+#if defined(__SSE2__)
+// This macro is mostly used to detect SSE2 extension.
 #define WEBRTC_ARCH_X86_FAMILY
+#endif
 #define WEBRTC_ARCH_X86
 #define WEBRTC_ARCH_32_BITS
 #define WEBRTC_ARCH_LITTLE_ENDIAN
--- a/webrtc_dsp/typedefs.h
+++ b/webrtc_dsp/typedefs.h
@@ -28,7 +28,10 @@
 #define WEBRTC_ARCH_64_BITS
 #define WEBRTC_ARCH_LITTLE_ENDIAN
 #elif defined(_M_IX86) || defined(__i386__)
+#if defined(__SSE2__)
+// This macro is mostly used to detect SSE2 extension.
 #define WEBRTC_ARCH_X86_FAMILY
+#endif
 #define WEBRTC_ARCH_X86
 #define WEBRTC_ARCH_32_BITS
 #define WEBRTC_ARCH_LITTLE_ENDIAN


code:
Copied from Debian.

Description: Fix build of  WebRTC on non-Linux systems
 * Define the WEBRTC_LINUX macro only on Linux, and not on GNU/Hurd or FreeBSD.
 * Fix type cast in the CurrentThreadId function.
Bug-Debian: https://bugs.debian.org/920851
Author: Nicholas Guriev <guriev-ns@ya.ru>
Last-Update: Tue, 29 Jan 2019 23:26:44 +0300

--- a/libtgvoip.gyp
+++ b/libtgvoip.gyp
@@ -869,20 +869,18 @@
             '"<(OS)" == "linux"', {
               'defines': [
                 'WEBRTC_POSIX',
-                'WEBRTC_LINUX',
               ],
               'conditions': [
                 [ '"<!(uname -m)" == "i686"', {
                   'cflags_cc': [
                     '-msse2',
                   ],
+                }], ['"<!(uname -s)" == "Linux"', {
+                  'defines': [
+                    'WEBRTC_LINUX',
+                  ],
                 }]
               ],
-              'direct_dependent_settings': {
-                'libraries': [
-
-                ],
-              },
             },
           ],
         ],
--- a/webrtc_dsp/rtc_base/platform_thread_types.cc
+++ b/webrtc_dsp/rtc_base/platform_thread_types.cc
@@ -31,7 +31,7 @@ PlatformThreadId CurrentThreadId() {
   return syscall(__NR_gettid);
 #else
   // Default implementation for nacl and solaris.
-  return reinterpret_cast<pid_t>(pthread_self());
+  return static_cast<pid_t>(pthread_self());
 #endif
 #endif  // defined(WEBRTC_POSIX)
 }


code:
Minimally patch libtheora's ancient config.guess to support mips64.

--- libtheora/config.guess.orig	2009-02-23 22:50:50.000000000 -0500
+++ libtheora/config.guess	2013-10-31 23:49:48.155999944 -0400
@@ -798,25 +798,24 @@
     m68*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
-    mips:Linux:*:*)
+    mips:Linux:*:* | mips64:Linux:*:*)
 	eval $set_cc_for_build
 	sed 's/^	//' << EOF >$dummy.c
 	#undef CPU
-	#undef mips
-	#undef mipsel
+	#undef ${UNAME_MACHINE}
+	#undef ${UNAME_MACHINE}el
 	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-	CPU=mipsel
+	CPU=${UNAME_MACHINE}el
 	#else
 	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-	CPU=mips
+	CPU=${UNAME_MACHINE}
 	#else
 	CPU=
 	#endif
 	#endif
 EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
-	rm -f $dummy.c && rmdir $tmpdir
-	test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit 0; }
 	;;
     ppc:Linux:*:*)
 	echo powerpc-unknown-linux-gnu


code:
Taken from https://salsa.debian.org/debian/libtirpc/-/raw/master/debian/patches/06-hurd-client-port.diff

Description: Fix client code for hurd, avoiding malloc overflow
 When trying to setup a inet connection, it happens the following:
 - in libtirp, src/clnt_vc.c, clnt_vc_create gets called
 - when trying to allocate vc_fd_locks, __rpc_dtbsize() is used as size
   for that array of fd locks
 - __rpc_dtbsize(), in src/rpc_generic.c, queries using rlimit the
   maximum (rlim_max) number of file descriptors (RLIMIT_NOFILE):
   - on Linux, the default is { rlim_cur = 1024, rlim_max = 4096 }
   - on kFreeBSD, the default is { rlim_cur = 1024, rlim_max = 1024 }
   - on Hurd, the default is { rlim_cur = 1024, rlim_max = RLIM_INFINITY }
  meaning that on Hurd the memory allocation fails (as
  __rpc_dtbsize() * sizeof(int) overflows and is negative)

 Change libtiprc so __rpc_dtbsize falls back on rlim_cur if rlim_max
 is unlimited.

 This patch fixes the client connection using inet sockets; local unix
 sockets are not working, for two reasons so far:
 - getpeername on them gives EOPNOTSUPP
 - SO_REUSEADDR is not implemented for them
Author: Pino Toscano <pino@debian.org>

Bug-Debian: http://bugs.debian.org/739674
Forwarded: no
Reviewed-By: Petter Reinholdtsen
Last-Update: 2014-03-03

--- a/src/rpc_generic.c
+++ b/src/rpc_generic.c
@@ -107,12 +107,17 @@
 {
 	static int tbsize;
 	struct rlimit rl;
+	rlim_t lim;

 	if (tbsize) {
 		return (tbsize);
 	}
 	if (getrlimit(RLIMIT_NOFILE, &rl) == 0) {
-		return (tbsize = (int)rl.rlim_max);
+		lim = rl.rlim_max;
+		if (lim == RLIM_INFINITY) {
+			lim = rl.rlim_cur;
+		}
+		return (tbsize = (int)lim);
 	}
 	/*
 	 * Something wrong.  I'll try to save face by returning a


code:
This is a combination of two patches:

1) Taken from https://salsa.debian.org/debian/libtirpc/-/raw/master/debian/patches/03-kfreebsd.diff

Description: Fix build on non Linux architectures
Author: Andreas Beckmann <anbe@debian.org>
Last-Update: 2019-09-01

2) Taken from https://salsa.debian.org/debian/libtirpc/-/raw/master/debian/patches/05-hurd-port.diff

Description: Get source building on Hurd
 - Look for <sys/user.h> before using it.
 - Define MAXHOSTNAMELEN to 64 if missing.
 - Bind sockets on Hurd like on Linux.
Author: Petter Reinholdtsen <pere@hungry.com>

--- a/src/svc_dg.c
+++ b/src/svc_dg.c
@@ -648,6 +648,7 @@
 void
 svc_dg_enable_pktinfo(int fd, const struct __rpc_sockinfo *si)
 {
+#ifdef __linux__
 	int val = 1;

 	switch (si->si_af) {
@@ -660,6 +661,7 @@
 		break;
 #endif
 	}
+#endif
 }

 /*
@@ -670,6 +672,7 @@
 int
 svc_dg_valid_pktinfo(struct msghdr *msg)
 {
+#ifdef __linux__
 	struct cmsghdr *cmsg;

 	if (!msg->msg_name)
@@ -716,4 +719,7 @@
 	}

 	return 1;
+#else
+        return 0;
+#endif
 }
--- a/src/clnt_vc.c
+++ b/src/clnt_vc.c
@@ -71,10 +71,12 @@
 #define MCALL_MSG_SIZE 24

 #define CMGROUP_MAX    16
-#define SCM_CREDS      0x03            /* process creds (struct cmsgcred) */

 #undef rpc_createerr                   /* make it clear it is a thread safe variable */

+#ifndef SCM_CREDS
+#define SCM_CREDS      0x03            /* process creds (struct cmsgcred) */
+
 /*
  * Credentials structure, used to verify the identity of a peer
  * process that has sent us a message. This is allocated by the
@@ -90,6 +92,7 @@
         short   cmcred_ngroups;         /* number or groups */
         gid_t   cmcred_groups[CMGROUP_MAX];     /* groups */
 };
+#endif

 struct cmessage {
         struct cmsghdr cmsg;
--- a/src/getpeereid.c
+++ b/src/getpeereid.c
@@ -25,9 +25,14 @@
  */

+#include "config.h"
+
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#ifdef HAVE_SYS_USER_H
+#  include <sys/user.h>
+#endif /* HAVE_SYS_USER_H */

 #include <errno.h>
 #include <unistd.h>
--- a/src/getpeereid.c
+++ b/src/getpeereid.c
@@ -35,12 +36,25 @@
 int
 getpeereid(int s, uid_t *euid, gid_t *egid)
 {
+#ifndef HAVE_SYS_USER_H
+        return(-1);
+#else
+#ifdef XUCRED_VERSION
+	struct xucred uc;
+#define uid  cr_uid
+#define gid  cr_gid
+#else
 	struct ucred uc;
+#endif
 	socklen_t uclen;
 	int error;

 	uclen = sizeof(uc);
+#ifdef XUCRED_VERSION
+	error = getsockopt(s, 0, LOCAL_PEERCRED, &uc, &uclen);
+#else
 	error = getsockopt(s, SOL_SOCKET, SO_PEERCRED, &uc, &uclen); /*  SCM_CREDENTIALS */
+#endif
 	if (error != 0)
 		return (error);
 	//	if (uc.cr_version != XUCRED_VERSION)
@@ -59,4 +66,5 @@
 	*euid = uc.uid;
 	*egid = uc.gid;
 	return (0);
+#endif /* HAVE_SYS_USER_H */
  }
--- a/tirpc/reentrant.h
+++ b/tirpc/reentrant.h
@@ -36,7 +36,7 @@
  * These definitions are only guaranteed to be valid on Linux.
  */

-#if defined(__linux__)
+#if defined(__linux__) || defined(__GLIBC__)

 #include <pthread.h>

--- a/configure.ac
+++ b/configure.ac
@@ -93,7 +93,7 @@
 AC_PROG_LIBTOOL
 AC_HEADER_DIRENT
 AC_PREFIX_DEFAULT(/usr)
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h locale.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h features.h gssapi/gssapi_ext.h])
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h locale.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h features.h gssapi/gssapi_ext.h sys/user.h])
 AC_CHECK_LIB([pthread], [pthread_create])
 AC_CHECK_FUNCS([getrpcbyname getrpcbynumber setrpcent endrpcent getrpcent])

--- a/src/auth_unix.c
+++ b/src/auth_unix.c
@@ -56,6 +56,11 @@
 #include <rpc/auth.h>
 #include <rpc/auth_unix.h>

+/* Workaround for Hurd */
+#ifndef MAXHOSTNAMELEN
+#  define MAXHOSTNAMELEN   64
+#endif
+
 /* auth_unix.c */
 static void authunix_nextverf (AUTH *);
 static bool_t authunix_marshal (AUTH *, XDR *);
--- a/src/bindresvport.c
+++ b/src/bindresvport.c
@@ -64,7 +64,7 @@
         return bindresvport_sa(sd, (struct sockaddr *)sin);
 }

-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)

 #define STARTPORT 600
 #define LOWPORT 512


code:
https://github.com/libtom/libtommath/commit/93dea3a4162527346cd8856bfda6f17ffe98ab04.patch

From 93dea3a4162527346cd8856bfda6f17ffe98ab04 Mon Sep 17 00:00:00 2001
From: Steffen Jaeckel <s@jaeckel.eu>
Date: Thu, 31 Jan 2019 14:12:03 +0100
Subject: [PATCH] makefile.shared: fix compilation and linkage

---
 makefile.shared | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/makefile.shared b/makefile.shared
index 3955f830..870b18d1 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -18,6 +18,7 @@ ifndef LIBTOOL
   endif
 endif
 LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC)
+LTLINK = $(LIBTOOL) --mode=link --tag=CC $(CC)

 LCOV_ARGS=--directory .libs --directory .

@@ -59,7 +60,7 @@ objs: $(OBJECTS)
 LOBJECTS = $(OBJECTS:.o=.lo)

 $(LIBNAME):  $(OBJECTS)
-	$(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_SO) $(LIBTOOLFLAGS)
+	$(LTLINK) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_SO) $(LIBTOOLFLAGS)

 install: $(LIBNAME)
 	install -d $(DESTDIR)$(LIBPATH)
@@ -76,16 +77,16 @@ uninstall:
 	rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc

 test: $(LIBNAME) demo/demo.o
-	$(CC) $(CFLAGS) -c demo/demo.c -o demo/demo.o
-	$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)
+	$(LTCOMPILE) $(CFLAGS) -c demo/demo.c -o demo/demo.o
+	$(LTLINK) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)

 test_standalone: $(LIBNAME) demo/demo.o
-	$(CC) $(CFLAGS) -c demo/demo.c -o demo/demo.o
-	$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)
+	$(LTCOMPILE) $(CFLAGS) -c demo/demo.c -o demo/demo.o
+	$(LTLINK) $(LDFLAGS) -o test demo/demo.o $(LIBNAME)

 .PHONY: mtest
 mtest:
-	cd mtest ; $(CC) $(CFLAGS) $(LDFLAGS) mtest.c -o mtest
+	cd mtest ; $(CC) $(CFLAGS) -O0 mtest.c $(LDFLAGS) -o mtest

 timing: $(LIBNAME) demo/timing.c
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o timing
+	$(LTLINK) $(CFLAGS) $(LDFLAGS) -DTIMER demo/timing.c $(LIBNAME) -o timing


code:
Skip the nopic test on ARM and MIPS systems.

--- libtool-2.4.6/tests/demo.at.orig	2015-01-16 13:52:04.000000000 -0500
+++ libtool-2.4.6/tests/demo.at	2015-02-16 10:48:51.435851966 -0500
@@ -510,7 +510,7 @@
 AT_SETUP([force non-PIC objects])

 AT_CHECK([case $host in
-hppa*|x86_64*|s390*)
+hppa*|x86_64*|s390*|arm*|mips*)
   # These hosts cannot use non-PIC shared libs
   exit 77 ;;
 *-solaris*|*-sunos*)
--- libtool-2.4.6/tests/testsuite.orig	2015-02-15 11:15:25.000000000 -0500
+++ libtool-2.4.6/tests/testsuite	2015-02-16 10:50:58.736483216 -0500
@@ -8741,7 +8741,7 @@

 { set +x
 $as_echo "$at_srcdir/demo.at:535: case \$host in
-hppa*|x86_64*|s390*)
+hppa*|x86_64*|s390*|arm*|mips*)
   # These hosts cannot use non-PIC shared libs
   exit 77 ;;
 *-solaris*|*-sunos*)
@@ -8766,7 +8766,7 @@
 "
 at_fn_check_prepare_notrace 'a `...` command substitution' "demo.at:535"
 ( $at_check_trace; case $host in
-hppa*|x86_64*|s390*)
+hppa*|x86_64*|s390*|arm*|mips*)
   # These hosts cannot use non-PIC shared libs
   exit 77 ;;
 *-solaris*|*-sunos*)


code:
Disable tests who fail because they have to run as root.

--- libusb-0.1.12/tests/Makefile.in	2006-03-04 03:54:06.000000000 +0100
+++ libusb-0.1.12/tests/Makefile.in	2017-07-13 16:17:45.201728019 +0200
@@ -255,8 +255,8 @@
 hub_strings_LDADD = $(top_builddir)/libusbpp.la @OSLIBS@
 driver_name_SOURCES = driver_name.cpp
 driver_name_LDADD = $(top_builddir)/libusbpp.la @OSLIBS@
-TESTS = testlibusb descriptor_test id_test find_hubs find_mice \
-		get_resolution hub_strings $(OS_SPECIFIC)
+TESTS = testlibusb descriptor_test id_test find_hubs find_mice
+		#get_resolution hub_strings $(OS_SPECIFIC)

 XFAIL_TESTS = get_resolution hub_strings $(OS_SPECIFIC_XFAIL)
 all: all-am


code:
diff --git a/libusb/descriptor.c b/libusb/descriptor.c
index 74d6de5..0b0e314 100644
--- a/libusb/descriptor.c
+++ b/libusb/descriptor.c
@@ -1174,7 +1174,7 @@ int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev_ha
 		return LIBUSB_ERROR_IO;

 	if (tbuf[0] > r)
-		return LIBUSB_ERROR_IO;
+		tbuf[0] = r;

 	di = 0;
 	for (si = 2; si < tbuf[0]; si += 2) {
--
2.17.0


code:
--- a/libutils/CallStack.cpp	2018-04-25 20:13:06.348665241 +0200
+++ b/libutils/CallStack.cpp	2018-04-25 20:13:18.360510763 +0200
@@ -17,7 +17,7 @@
 #define LOG_TAG "CallStack"

 #include <memory>
-
+#include <cstdlib>
 #include <utils/CallStack.h>
 #include <utils/Printer.h>
 #include <utils/Errors.h>


code:
--- a/include/utils/StrongPointer.h	2018-04-25 18:42:34.321003602 +0200
+++ b/include/utils/StrongPointer.h	2018-04-25 18:42:42.180912201 +0200
@@ -17,8 +17,6 @@
 #ifndef ANDROID_STRONG_POINTER_H
 #define ANDROID_STRONG_POINTER_H

-#include <cutils/atomic.h>
-
 #include <stdint.h>
 #include <sys/types.h>
 #include <stdlib.h>
--- a/libutils/Trace.cpp	2018-04-25 20:41:48.775049786 +0200
+++ b/libutils/Trace.cpp	2018-04-25 20:42:13.674744182 +0200
@@ -21,5 +21,7 @@

 static void traceInit()
 {
+#if defined(__ANDROID__)
     ::android::add_sysprop_change_callback(atrace_update_tags, 0);
+#endif
 }


code:
From 18e3ff648356cf06a39372aa4a4bbf2732d9d0f4 Mon Sep 17 00:00:00 2001
From: Efraim Flashner <efraim@flashner.co.il>
Date: Tue, 12 Dec 2017 21:36:44 +0200
Subject: [PATCH] don't use bundled libvdpau headers

---
 CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0484179..e950707 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,16 +9,17 @@ find_package(PkgConfig REQUIRED)
 find_package(X11 REQUIRED)
 pkg_check_modules(LIBVA      libva-x11  REQUIRED)
 pkg_check_modules(LIBGL      gl         REQUIRED)
+pkg_check_modules(LIBVDPAU   vdpau      REQUIRED)

 set(DRIVER_NAME "vdpau_va_gl" CACHE STRING "driver name")
 set(LIB_SUFFIX "" CACHE STRING "library path suffix (if needed)")
 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/vdpau" CACHE PATH "library installation path")

 include_directories (
-    3rdparty
     ${X11_INCLUDE_DIRS}
     ${LIBVA_INCLUDE_DIRS}
     ${LIBGL_INCLUDE_DIRS}
+    ${LIBVDPAU_INCLUDE_DIRS}
     ${GENERATED_INCLUDE_DIRS}
     ${CMAKE_BINARY_DIR}
 )
--
2.15.1


code:
From 9ca0b2955edea162b255b428e493cd8ffac52167 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?=
 <rosen644835@gmail.com>
Date: Fri, 1 Nov 2019 17:29:00 +0100
Subject: [PATCH] vircgroup: Ensure /machine group is associated with its
 parent.

Call first virCgroupNew on the parent group virCgroupNewPartition if
it is available on before the creation of the child group.  This
ensures that the creation of a first level group on the unified
architecture, as the check at virCgroupV2ParseControllersFile as the
parent file is there.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1760233
---
 src/util/vircgroup.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index b46f20abfd..33c61f2d45 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -855,9 +855,6 @@ virCgroupNewPartition(const char *path,
     if (virCgroupSetPartitionSuffix(path, &newPath) < 0)
         goto cleanup;

-    if (virCgroupNew(-1, newPath, NULL, controllers, group) < 0)
-        goto cleanup;
-
     if (STRNEQ(newPath, "/")) {
         char *tmp;
         parentPath = g_strdup(newPath);
@@ -868,7 +865,12 @@ virCgroupNewPartition(const char *path,

         if (virCgroupNew(-1, parentPath, NULL, controllers, &parent) < 0)
             goto cleanup;
+    }

+    if (virCgroupNew(-1, newPath, parent, controllers, group) < 0)
+        goto cleanup;
+
+    if (parent) {
         if (virCgroupMakeGroup(parent, *group, create, VIR_CGROUP_NONE) < 0)
             goto cleanup;
     }
--
2.23.0


code:
Patch contents copied from Mozilla esr45 changeset 312077:7ebfe49f001c

  changeset:   312077:7ebfe49f001c
  user:        Randell Jesup <rjesup@jesup.org>
  Date:        Fri Apr 15 23:11:01 2016 -0400
  summary:     Bug 1263384: validate input frames against configured resolution in vp8 r=rillian, a=ritu,lizzard

  MozReview-Commit-ID: BxDCnJe0mzs

--- libvpx-1.5.0/vp8/vp8_cx_iface.c.orig	2015-11-09 17:12:38.000000000 -0500
+++ libvpx-1.5.0/vp8/vp8_cx_iface.c	2016-06-08 08:48:46.037213092 -0400
@@ -860,11 +860,20 @@
     if (img != NULL) {
       res = image2yuvconfig(img, &sd);

-      if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags, &sd,
-                                dst_time_stamp, dst_end_time_stamp)) {
-        VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;
-        res = update_error_state(ctx, &cpi->common.error);
-      }
+            if (sd.y_width != ctx->cfg.g_w || sd.y_height != ctx->cfg.g_h) {
+                /* from vp8_encoder.h for g_w/g_h:
+                   "Note that the frames passed as input to the encoder must have this resolution"
+                */
+                ctx->base.err_detail = "Invalid input frame resolution";
+                res = VPX_CODEC_INVALID_PARAM;
+            } else {
+                if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags,
+                                          &sd, dst_time_stamp, dst_end_time_stamp))
+                {
+                    VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;
+                    res = update_error_state(ctx, &cpi->common.error);
+                }
+            }

       /* reset for next frame */
       ctx->next_frame_flag = 0;


code:
This makes generated IDs deterministic.

Written by Daniel Veillard.

This should be fixed in next release (2.29).
See https://bugzilla.gnome.org/show_bug.cgi?id=751621.

diff --git a/libxslt/functions.c b/libxslt/functions.c
index 6448bde..5b00a6d 100644
--- a/libxslt/functions.c
+++ b/libxslt/functions.c
@@ -651,6 +651,63 @@ xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs)
 }

 /**
+ * xsltCleanupIds:
+ * @ctxt: the transformation context
+ * @root: the root of the resulting document
+ *
+ * This clean up ids which may have been saved in Element contents
+ * by xsltGenerateIdFunction() to provide stable IDs on elements.
+ *
+ * Returns the number of items cleaned or -1 in case of error
+ */
+int
+xsltCleanupIds(xsltTransformContextPtr ctxt, xmlNodePtr root) {
+    xmlNodePtr cur;
+    int count = 0;
+
+    if ((ctxt == NULL) || (root == NULL))
+        return(-1);
+    if (root->type != XML_ELEMENT_NODE)
+        return(-1);
+
+    cur = root;
+    while (cur != NULL) {
+	if (cur->type == XML_ELEMENT_NODE) {
+	    if (cur->content != NULL) {
+	        cur->content = NULL;
+		count++;
+	    }
+	    if (cur->children != NULL) {
+		cur = cur->children;
+		continue;
+	    }
+	}
+	if (cur->next != NULL) {
+	    cur = cur->next;
+	    continue;
+	}
+	do {
+	    cur = cur->parent;
+	    if (cur == NULL)
+		break;
+	    if (cur == (xmlNodePtr) root) {
+		cur = NULL;
+		break;
+	    }
+	    if (cur->next != NULL) {
+		cur = cur->next;
+		break;
+	    }
+	} while (cur != NULL);
+    }
+
+fprintf(stderr, "Attributed %d IDs for element, cleaned up %d\n",
+        ctxt->nextid, count);
+
+    return(count);
+}
+
+/**
  * xsltGenerateIdFunction:
  * @ctxt:  the XPath Parser context
  * @nargs:  the number of arguments
@@ -701,7 +758,39 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
     if (obj)
         xmlXPathFreeObject(obj);

-    val = (long)((char *)cur - (char *)&base_address);
+    /*
+     * Try to provide stable ID for generated document:
+     *   - usually ID are computed to be placed on elements via attributes
+     *     so using the element as the node for the ID
+     *   - the cur->content should be a correct placeholder for this, we use
+     *     it to hold element node numbers in xmlXPathOrderDocElems to
+     *     speed up XPath too
+     *   - xsltCleanupIds() clean them up before handing the XSLT output
+     *     to the API client.
+     *   - other nodes types use the node address method but that should
+     *     not end up in resulting document ID
+     *   - we can enable this by default without risk of performance issues
+     *     only the one pass xsltCleanupIds() is added
+     */
+    if (cur->type == XML_ELEMENT_NODE) {
+        if (cur->content == NULL) {
+	    xsltTransformContextPtr tctxt;
+
+	    tctxt = xsltXPathGetTransformContext(ctxt);
+	    if (tctxt == NULL) {
+		val = (long)((char *)cur - (char *)&base_address);
+	    } else {
+		tctxt->nextid++;
+		val = tctxt->nextid;
+		cur->content = (void *) (val);
+	    }
+	} else {
+	    val = (long) cur->content;
+	}
+    } else {
+	val = (long)((char *)cur - (char *)&base_address);
+    }
+
     if (val >= 0) {
       sprintf((char *)str, "idp%ld", val);
     } else {
diff --git a/libxslt/functions.h b/libxslt/functions.h
index e0e0bf9..4a1e163 100644
--- a/libxslt/functions.h
+++ b/libxslt/functions.h
@@ -64,6 +64,13 @@ XSLTPUBFUN void XSLTCALL
 					 int nargs);

 /*
+ * Cleanup for ID generation
+ */
+XSLTPUBFUN int XSLTCALL
+	xsltCleanupIds			(xsltTransformContextPtr ctxt,
+					 xmlNodePtr root);
+
+/*
  * And the registration
  */

diff --git a/libxslt/transform.c b/libxslt/transform.c
index 24f9eb2..2bdf6bf 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -700,6 +700,7 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
     cur->traceCode = (unsigned long*) &xsltDefaultTrace;
     cur->xinclude = xsltGetXIncludeDefault();
     cur->keyInitLevel = 0;
+    cur->nextid = 0;

     return(cur);

@@ -6092,6 +6093,13 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
     if (root != NULL) {
         const xmlChar *doctype = NULL;

+        /*
+	 * cleanup ids which may have been saved in Elements content ptrs
+	 */
+	if (ctxt->nextid != 0) {
+	    xsltCleanupIds(ctxt, root);
+	}
+
         if ((root->ns != NULL) && (root->ns->prefix != NULL))
 	    doctype = xmlDictQLookup(ctxt->dict, root->ns->prefix, root->name);
 	if (doctype == NULL)
diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h
index 95e8fe6..8eedae4 100644
--- a/libxslt/xsltInternals.h
+++ b/libxslt/xsltInternals.h
@@ -1782,6 +1782,8 @@ struct _xsltTransformContext {
     int maxTemplateVars;
     unsigned long opLimit;
     unsigned long opCount;
+
+    unsigned long nextid;/* for generating stable ids */
 };

 /**


code:
diff --git a/src/Intrinsic.c b/src/Intrinsic.c
index c9624ec..addcdba 100644
--- a/src/Intrinsic.c
+++ b/src/Intrinsic.c
@@ -1312,21 +1312,101 @@ static void FillInLangSubs(
     } else (void) strcpy(*rest, string);
 }

+
+
 /*
- * default path used if environment variable XFILESEARCHPATH
- * is not defined.  Also substitued for %D.
- * The exact value should be documented in the implementation
- * notes for any Xt implementation.
+   Return the default search path for the function
+   XtResolvePathname to use if XFILESEARCHPATH is
+   not defined.
+
+   It returns the combination the set of values which are the 6 "stems" below,
+   prepended with "/run/current-system/profile", and $GUIX_PROFILE and
+   "$HOME/.guix-profile"
+
+   These values provide the default paths where Guix/GuixSD can expect
+   to find resources for installed packages.
  */
-static const char *implementation_default_path(void)
+static const char *guix_default_path(void)
 {
-#if defined(WIN32)
-    static char xfilesearchpath[] = "";
+  static const char *search_path_default_stem[] = {
+    "/lib/X11/%L/%T/%N%C%S",
+    "/lib/X11/%l/%T/%N%C%S",
+    "/lib/X11/%T/%N%C%S",
+    "/lib/X11/%L/%T/%N%S",
+    "/lib/X11/%l/%T/%N%S",
+    "/lib/X11/%T/%N%S"
+  };
+
+#define SIZEOF_STEMS  (strlen (search_path_default_stem[0])	\
+		       + strlen (search_path_default_stem[1])	\
+		       + strlen (search_path_default_stem[2])	\
+		       + strlen (search_path_default_stem[3])	\
+		       + strlen (search_path_default_stem[4])	\
+		       + strlen (search_path_default_stem[5]))
+
+
+  int i;
+  const char *current_profile = "/run/current-system/profile";
+  char *home = getenv ("HOME");
+  char *guix_profile = getenv ("GUIX_PROFILE");
+
+  size_t bytesAllocd = SIZEOF_STEMS + 1;
+
+  /* This function is evaluated multiple times and the calling
+     code assumes that it is idempotent. So we must not allow
+     (say) a changed environment variable to cause it to return
+     something different. */
+  static char *path = NULL;
+  if (path)
+    return path;
+
+  bytesAllocd += 6 * (1 + strlen (current_profile));
+
+  if (guix_profile != NULL)
+    {
+      bytesAllocd += SIZEOF_STEMS;
+      bytesAllocd += 6 * (1 + strlen (guix_profile));
+    }

-    return xfilesearchpath;
-#else
-    return XFILESEARCHPATHDEFAULT;
-#endif
+  if (home != NULL)
+    {
+      bytesAllocd += SIZEOF_STEMS;
+      bytesAllocd += 6 * (1 + strlen(home) + strlen ("/.guix-profile"));
+    }
+
+  path = XtMalloc(bytesAllocd);
+  if (path == NULL) _XtAllocError(NULL);
+
+  memset (path, 0, bytesAllocd);
+
+  for (i = 0 ; i < 6 ; ++i)
+    {
+      strcat (path, current_profile);
+      strcat (path, search_path_default_stem[i]);
+      strcat (path, ":");
+    }
+
+  if (guix_profile != NULL)
+    for (i = 0 ; i < 6 ; ++i)
+      {
+	strcat (path, guix_profile);
+	strcat (path, search_path_default_stem[i]);
+	strcat (path, ":");
+      }
+
+  if (home != NULL)
+    for (i = 0 ; i < 6 ; ++i)
+      {
+	strcat (path, home);
+	strcat (path, "/.guix-profile");
+	strcat (path, search_path_default_stem[i]);
+	strcat (path, ":");
+      }
+
+  /* Remove final : */
+  path[strlen(path) - 1] = '\0';
+
+  return path;
 }

@@ -1354,7 +1434,7 @@ _XtString XtResolvePathname(
 {
     XtPerDisplay pd;
     static const char *defaultPath = NULL;
-    const char *impl_default = implementation_default_path();
+    const char *impl_default = guix_default_path();
     int idef_len = (int) strlen(impl_default);
     char *massagedPath;
     int bytesAllocd, bytesLeft;


code:
--- a/libziparchive/zip_writer.cc	2018-04-25 22:33:05.472674164 +0200
+++ b/libziparchive/zip_writer.cc	2018-04-25 22:33:21.296519518 +0200
@@ -22,6 +22,7 @@

 #include <sys/param.h>

+#include <cstring>
 #include <cassert>
 #include <cstdio>
 #include <memory>


code:
Patch copied from Debian:

https://anonscm.debian.org/cgit/pkg-games/lierolibre.git/tree/debian/patches/0001-Use-unaligned-access-define-over-checking-arch.patch?id=82910748906855f6e6bfe30b3f077e8c793ae424

From 396f19b6b7743d394307f70f0c0108419824437b Mon Sep 17 00:00:00 2001
From: Martin Erik Werner <martinerikwerner@gmail.com>
Date: Sun, 28 Jun 2015 16:31:34 +0200
Subject: [PATCH 1/3] Use unaligned access define over checking arch

This todo item seems like it done, and just needed implementing...
---
 io/encoding.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gvl/io/encoding.hpp b/src/gvl/io/encoding.hpp
index c491677..89bb612 100644
--- a/src/gvl/io/encoding.hpp
+++ b/src/gvl/io/encoding.hpp
@@ -374,7 +374,7 @@ struct octet_stream_writer
 		// inlining of the common case
 		if(std::size_t(end_ - cur_) >= len)
 		{
-#if GVL_X86 || GVL_X86_64 // TODO: A define that says whether unaligned access is allowed
+#if GVL_UNALIGNED_ACCESS
 			if(len < 64) // TODO: Tweak this limit
 			{
 				while(len > 4)
--
2.4.6


code:
Remove outdated license text. See COPYING and the description
at http://liero.be/ for more information.

--- a/data/LIEROENG.TXT
+++ b/data/LIEROENG.TXT
@@ -11,14 +11,6 @@
 -----------------------------------------------------------------------------

 GENERAL STUFF
-
-	Liero is freeware. What that means is that you don't have to pay
-	for it and using it has not been restricted in any way. You may
-        distribute it to anyone and anyhow WITHOUT ANY CHANGES MADE TO IT'S
-	CONTAINMENTS.
-
-	The source code of this game is not distributed freely (neither
-        commercially). So if you thought that maybe you could... forget it.

 	Liero is a wormgame with weapons for 2 players. The object of the
 	game is definately what you think it is. Liero is excellent for
--- a/data/LIERO.TXT
+++ b/data/LIERO.TXT
@@ -12,15 +12,6 @@

 YLEIST�

-        Liero on freeware, mik� tarkoittaa ett� sen k�yt�st� ei tarvitse
-        maksaa mit��n eik� k�ytt�� ole rajoitettu mitenk��n. Lieroa saa
-        kopioida kelle tahansa ja miten tahansa SIS�LT�� MITENK��N
-        MUUTTAMATTA.
-
-        Todettakoon t�ss� ett� Lieron l�hdekoodi ei ole vapaassa (sen
-        enenp�� kuin kaupallisessakaan) jakelussa. Joten jos ajattelit
-        ett�... niin j�t� ajatukset sikseen.
-
         Liero on kahden pelattava aseellinen matosimulaatiopeli. Pelin
         p��m��r�n� on ep�ilem�tt� se mit� luuletkin. Liero sopii
         erinomaisen hyvin aggressioiden purkuun ja kaverin rokitt�miseen