code:
Fix an overflow when calculating something for AVC/HEVC videos:

https://security-tracker.debian.org/tracker/TEMP-0000000-C6AAE1

Patch copied from upstream source repository:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/commit/0cfbf7ad91c7f121192c8ce135769f8eb276c41d
From 0cfbf7ad91c7f121192c8ce135769f8eb276c41d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
Date: Tue, 23 Mar 2021 19:19:14 +0200
Subject: [PATCH] h2645parser: Catch overflows in AVC/HEVC NAL unit length
 calculations

Offset and size are stored as 32 bit guint and might overflow when
adding the nal_length_size, so let's avoid that.

For the size this would happen if the AVC/HEVC NAL unit size happens to
be stored in 4 bytes and is 4294967292 or higher, which is likely
corrupted data anyway.

For the offset this is something for the caller of these functions to
take care of but is unlikely to happen as it would require parsing on a
>4GB buffer.

Allowing these overflows causes all kinds of follow-up bugs in the
h2645parse elements, ranging from infinite loops and memory leaks to
potential memory corruptions.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2107>
---
 gst-libs/gst/codecparsers/gsth264parser.c | 16 +++++-
 gst-libs/gst/codecparsers/gsth265parser.c | 16 +++++-
 tests/check/libs/h264parser.c             | 60 +++++++++++++++++++++++
 tests/check/libs/h265parser.c             | 60 +++++++++++++++++++++++
 4 files changed, 150 insertions(+), 2 deletions(-)

diff --git a/gst-libs/gst/codecparsers/gsth264parser.c b/gst-libs/gst/codecparsers/gsth264parser.c
index 012f1d0d7..68aa25068 100644
--- a/gst-libs/gst/codecparsers/gsth264parser.c
+++ b/gst-libs/gst/codecparsers/gsth264parser.c
@@ -1556,6 +1556,14 @@ gst_h264_parser_identify_nalu_avc (GstH264NalParser * nalparser,

   memset (nalu, 0, sizeof (*nalu));

+  /* Would overflow guint below otherwise: the callers needs to ensure that
+   * this never happens */
+  if (offset > G_MAXUINT32 - nal_length_size) {
+    GST_WARNING ("offset + nal_length_size overflow");
+    nalu->size = 0;
+    return GST_H264_PARSER_BROKEN_DATA;
+  }
+
   if (size < offset + nal_length_size) {
     GST_DEBUG ("Can't parse, buffer has too small size %" G_GSIZE_FORMAT
         ", offset %u", size, offset);
@@ -1570,7 +1578,13 @@ gst_h264_parser_identify_nalu_avc (GstH264NalParser * nalparser,
   nalu->sc_offset = offset;
   nalu->offset = offset + nal_length_size;

-  if (size < nalu->size + nal_length_size) {
+  if (nalu->size > G_MAXUINT32 - nal_length_size) {
+    GST_WARNING ("NALU size + nal_length_size overflow");
+    nalu->size = 0;
+    return GST_H264_PARSER_BROKEN_DATA;
+  }
+
+  if (size < (gsize) nalu->size + nal_length_size) {
     nalu->size = 0;

     return GST_H264_PARSER_NO_NAL_END;
diff --git a/gst-libs/gst/codecparsers/gsth265parser.c b/gst-libs/gst/codecparsers/gsth265parser.c
index 26e68b276..dc7f27aa9 100644
--- a/gst-libs/gst/codecparsers/gsth265parser.c
+++ b/gst-libs/gst/codecparsers/gsth265parser.c
@@ -1531,6 +1531,14 @@ gst_h265_parser_identify_nalu_hevc (GstH265Parser * parser,

   memset (nalu, 0, sizeof (*nalu));

+  /* Would overflow guint below otherwise: the callers needs to ensure that
+   * this never happens */
+  if (offset > G_MAXUINT32 - nal_length_size) {
+    GST_WARNING ("offset + nal_length_size overflow");
+    nalu->size = 0;
+    return GST_H265_PARSER_BROKEN_DATA;
+  }
+
   if (size < offset + nal_length_size) {
     GST_DEBUG ("Can't parse, buffer has too small size %" G_GSIZE_FORMAT
         ", offset %u", size, offset);
@@ -1545,7 +1553,13 @@ gst_h265_parser_identify_nalu_hevc (GstH265Parser * parser,
   nalu->sc_offset = offset;
   nalu->offset = offset + nal_length_size;

-  if (size < nalu->size + nal_length_size) {
+  if (nalu->size > G_MAXUINT32 - nal_length_size) {
+    GST_WARNING ("NALU size + nal_length_size overflow");
+    nalu->size = 0;
+    return GST_H265_PARSER_BROKEN_DATA;
+  }
+
+  if (size < (gsize) nalu->size + nal_length_size) {
     nalu->size = 0;

     return GST_H265_PARSER_NO_NAL_END;
diff --git a/tests/check/libs/h264parser.c b/tests/check/libs/h264parser.c
index c7c46d9a2..d322dd8db 100644
--- a/tests/check/libs/h264parser.c
+++ b/tests/check/libs/h264parser.c
@@ -229,6 +229,65 @@ GST_START_TEST (test_h264_parse_slice_5bytes)

 GST_END_TEST;

+GST_START_TEST (test_h264_parse_identify_nalu_avc)
+{
+  GstH264ParserResult res;
+  GstH264NalUnit nalu;
+  GstH264NalParser *const parser = gst_h264_nal_parser_new ();
+  /* Skip 3 bytes for the start code */
+  const gsize nal_size = sizeof (slice_dpa) - 3;
+  const gsize buf_size = 4 + nal_size;
+  guint8 *buf = g_new (guint8, buf_size);
+
+  memcpy (buf + 4, slice_dpa + 3, nal_size);
+
+  GST_WRITE_UINT16_BE (buf + 2, nal_size);
+  res = gst_h264_parser_identify_nalu_avc (parser, buf, 2, buf_size, 2, &nalu);
+
+  assert_equals_int (res, GST_H264_PARSER_OK);
+  assert_equals_int (nalu.type, GST_H264_NAL_SLICE_DPA);
+  assert_equals_int (nalu.offset, 4);
+  assert_equals_int (nalu.size, nal_size);
+
+  GST_WRITE_UINT32_BE (buf, nal_size);
+  res = gst_h264_parser_identify_nalu_avc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H264_PARSER_OK);
+  assert_equals_int (nalu.type, GST_H264_NAL_SLICE_DPA);
+  assert_equals_int (nalu.offset, 4);
+  assert_equals_int (nalu.size, nal_size);
+
+  GST_WRITE_UINT32_BE (buf, G_MAXUINT32);
+  res = gst_h264_parser_identify_nalu_avc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H264_PARSER_BROKEN_DATA);
+
+  GST_WRITE_UINT32_BE (buf, G_MAXUINT32 - 2);
+  res = gst_h264_parser_identify_nalu_avc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H264_PARSER_BROKEN_DATA);
+
+  GST_WRITE_UINT32_BE (buf, G_MAXUINT32 - 3);
+  res = gst_h264_parser_identify_nalu_avc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H264_PARSER_BROKEN_DATA);
+
+  GST_WRITE_UINT32_BE (buf, G_MAXUINT32 - 4);
+  res = gst_h264_parser_identify_nalu_avc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H264_PARSER_NO_NAL_END);
+
+  GST_WRITE_UINT32_BE (buf, G_MAXUINT32 - 6);
+  res = gst_h264_parser_identify_nalu_avc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H264_PARSER_NO_NAL_END);
+
+  g_free (buf);
+  gst_h264_nal_parser_free (parser);
+}
+
+GST_END_TEST;
+
 static guint8 nalu_sps_with_vui[] = {
   0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x28,
   0xac, 0xd9, 0x40, 0x78, 0x04, 0x4f, 0xde, 0x03,
@@ -666,6 +725,7 @@ h264parser_suite (void)
   tcase_add_test (tc_chain, test_h264_parse_slice_dpa);
   tcase_add_test (tc_chain, test_h264_parse_slice_eoseq_slice);
   tcase_add_test (tc_chain, test_h264_parse_slice_5bytes);
+  tcase_add_test (tc_chain, test_h264_parse_identify_nalu_avc);
   tcase_add_test (tc_chain, test_h264_parse_invalid_sei);
   tcase_add_test (tc_chain, test_h264_create_sei);

diff --git a/tests/check/libs/h265parser.c b/tests/check/libs/h265parser.c
index 0a0e4db97..5b6a215ec 100644
--- a/tests/check/libs/h265parser.c
+++ b/tests/check/libs/h265parser.c
@@ -255,6 +255,65 @@ GST_START_TEST (test_h265_parse_slice_6bytes)

 GST_END_TEST;

+GST_START_TEST (test_h265_parse_identify_nalu_hevc)
+{
+  GstH265ParserResult res;
+  GstH265NalUnit nalu;
+  GstH265Parser *parser = gst_h265_parser_new ();
+  /* Skip 4 bytes for the start code */
+  const gsize nal_size = sizeof (slice_eos_slice_eob) - 4;
+  const gsize buf_size = 4 + nal_size;
+  guint8 *buf = g_new (guint8, buf_size);
+
+  memcpy (buf + 4, slice_eos_slice_eob + 4, nal_size);
+
+  GST_WRITE_UINT16_BE (buf + 2, nal_size);
+  res = gst_h265_parser_identify_nalu_hevc (parser, buf, 2, buf_size, 2, &nalu);
+
+  assert_equals_int (res, GST_H265_PARSER_OK);
+  assert_equals_int (nalu.type, GST_H265_NAL_SLICE_IDR_W_RADL);
+  assert_equals_int (nalu.offset, 4);
+  assert_equals_int (nalu.size, nal_size);
+
+  GST_WRITE_UINT32_BE (buf, nal_size);
+  res = gst_h265_parser_identify_nalu_hevc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H265_PARSER_OK);
+  assert_equals_int (nalu.type, GST_H265_NAL_SLICE_IDR_W_RADL);
+  assert_equals_int (nalu.offset, 4);
+  assert_equals_int (nalu.size, nal_size);
+
+  GST_WRITE_UINT32_BE (buf, G_MAXUINT32);
+  res = gst_h265_parser_identify_nalu_hevc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H265_PARSER_BROKEN_DATA);
+
+  GST_WRITE_UINT32_BE (buf, G_MAXUINT32 - 2);
+  res = gst_h265_parser_identify_nalu_hevc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H265_PARSER_BROKEN_DATA);
+
+  GST_WRITE_UINT32_BE (buf, G_MAXUINT32 - 3);
+  res = gst_h265_parser_identify_nalu_hevc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H265_PARSER_BROKEN_DATA);
+
+  GST_WRITE_UINT32_BE (buf, G_MAXUINT32 - 4);
+  res = gst_h265_parser_identify_nalu_hevc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H265_PARSER_NO_NAL_END);
+
+  GST_WRITE_UINT32_BE (buf, G_MAXUINT32 - 6);
+  res = gst_h265_parser_identify_nalu_hevc (parser, buf, 0, buf_size, 4, &nalu);
+
+  assert_equals_int (res, GST_H265_PARSER_NO_NAL_END);
+
+  g_free (buf);
+  gst_h265_parser_free (parser);
+}
+
+GST_END_TEST;
+
 GST_START_TEST (test_h265_base_profiles)
 {
   GstH265ProfileTierLevel ptl;
@@ -1101,6 +1160,7 @@ h265parser_suite (void)
   tcase_add_test (tc_chain, test_h265_parse_slice_eos_slice_eob);
   tcase_add_test (tc_chain, test_h265_parse_pic_timing);
   tcase_add_test (tc_chain, test_h265_parse_slice_6bytes);
+  tcase_add_test (tc_chain, test_h265_parse_identify_nalu_hevc);
   tcase_add_test (tc_chain, test_h265_base_profiles);
   tcase_add_test (tc_chain, test_h265_base_profiles_compat);
   tcase_add_test (tc_chain, test_h265_format_range_profiles_exact_match);
--
2.31.1


code:
Fix an "invalid read during ID3v2 tag parsing".

https://security-tracker.debian.org/tracker/TEMP-0000000-57E7C1
https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/876

Patch copied from upstream source repository:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/commit/f4a1428a6997658625d529b9db60fde812fbf1ee

From f4a1428a6997658625d529b9db60fde812fbf1ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= <tim@centricular.com>
Date: Wed, 3 Mar 2021 01:08:25 +0000
Subject: [PATCH] tag: id3v2: fix frame size check and potential invalid reads

Check the right variable when checking if there's
enough data left to read the frame size.

Closes https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/876

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1065>
---
 gst-libs/gst/tag/id3v2frames.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gst-libs/gst/tag/id3v2frames.c b/gst-libs/gst/tag/id3v2frames.c
index 8e9f78254..f39659bf7 100644
--- a/gst-libs/gst/tag/id3v2frames.c
+++ b/gst-libs/gst/tag/id3v2frames.c
@@ -109,7 +109,7 @@ id3v2_parse_frame (ID3TagsWorking * work)

   if (work->frame_flags & (ID3V2_FRAME_FORMAT_COMPRESSION |
           ID3V2_FRAME_FORMAT_DATA_LENGTH_INDICATOR)) {
-    if (work->hdr.frame_data_size <= 4)
+    if (frame_data_size <= 4)
       return FALSE;
     if (ID3V2_VER_MAJOR (work->hdr.version) == 3) {
       work->parse_size = GST_READ_UINT32_BE (frame_data);
--
2.31.1

repo_name: maximed/guix

license: mit


code:
Fix CVE-2021-3497:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-3497
https://gstreamer.freedesktop.org/security/sa-2021-0002.html

Patch copied from upstream source repository:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/commit/9181191511f9c0be6a89c98b311f49d66bd46dc3?merge_request_iid=903

diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
index 467815986c8c3d86fd8906a0d539b34f67d6693e..0e47ee7b5e25ac3331f30439710ae755235f2a22 100644
--- a/gst/matroska/matroska-demux.c
+++ b/gst/matroska/matroska-demux.c
@@ -3851,6 +3851,12 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
     guint32 block_samples, tmp;
     gsize size = gst_buffer_get_size (*buf);

+    if (size < 4) {
+      GST_ERROR_OBJECT (element, "Too small wavpack buffer");
+      gst_buffer_unmap (*buf, &map);
+      return GST_FLOW_ERROR;
+    }
+
     gst_buffer_extract (*buf, 0, &tmp, sizeof (guint32));
     block_samples = GUINT32_FROM_LE (tmp);
     /* we need to reconstruct the header of the wavpack block */
@@ -3858,10 +3864,10 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
     /* -20 because ck_size is the size of the wavpack block -8
      * and lace_size is the size of the wavpack block + 12
      * (the three guint32 of the header that already are in the buffer) */
-    wvh.ck_size = size + sizeof (Wavpack4Header) - 20;
+    wvh.ck_size = size + WAVPACK4_HEADER_SIZE - 20;

     /* block_samples, flags and crc are already in the buffer */
-    newbuf = gst_buffer_new_allocate (NULL, sizeof (Wavpack4Header) - 12, NULL);
+    newbuf = gst_buffer_new_allocate (NULL, WAVPACK4_HEADER_SIZE - 12, NULL);

     gst_buffer_map (newbuf, &outmap, GST_MAP_WRITE);
     data = outmap.data;
@@ -3886,9 +3892,11 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
     audiocontext->wvpk_block_index += block_samples;
   } else {
     guint8 *outdata = NULL;
-    guint outpos = 0;
-    gsize buf_size, size, out_size = 0;
+    gsize buf_size, size;
     guint32 block_samples, flags, crc, blocksize;
+    GstAdapter *adapter;
+
+    adapter = gst_adapter_new ();

     gst_buffer_map (*buf, &map, GST_MAP_READ);
     buf_data = map.data;
@@ -3897,6 +3905,7 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
     if (buf_size < 4) {
       GST_ERROR_OBJECT (element, "Too small wavpack buffer");
       gst_buffer_unmap (*buf, &map);
+      g_object_unref (adapter);
       return GST_FLOW_ERROR;
     }

@@ -3918,59 +3927,57 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
       data += 4;
       size -= 4;

-      if (blocksize == 0 || size < blocksize)
-        break;
-
-      g_assert ((newbuf == NULL) == (outdata == NULL));
+      if (blocksize == 0 || size < blocksize) {
+        GST_ERROR_OBJECT (element, "Too small wavpack buffer");
+        gst_buffer_unmap (*buf, &map);
+        g_object_unref (adapter);
+        return GST_FLOW_ERROR;
+      }

-      if (newbuf == NULL) {
-        out_size = sizeof (Wavpack4Header) + blocksize;
-        newbuf = gst_buffer_new_allocate (NULL, out_size, NULL);
+      g_assert (newbuf == NULL);

-        gst_buffer_copy_into (newbuf, *buf,
-            GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS, 0, -1);
+      newbuf =
+          gst_buffer_new_allocate (NULL, WAVPACK4_HEADER_SIZE + blocksize,
+          NULL);
+      gst_buffer_map (newbuf, &outmap, GST_MAP_WRITE);
+      outdata = outmap.data;
+
+      outdata[0] = 'w';
+      outdata[1] = 'v';
+      outdata[2] = 'p';
+      outdata[3] = 'k';
+      outdata += 4;
+
+      GST_WRITE_UINT32_LE (outdata, blocksize + WAVPACK4_HEADER_SIZE - 8);
+      GST_WRITE_UINT16_LE (outdata + 4, wvh.version);
+      GST_WRITE_UINT8 (outdata + 6, wvh.track_no);
+      GST_WRITE_UINT8 (outdata + 7, wvh.index_no);
+      GST_WRITE_UINT32_LE (outdata + 8, wvh.total_samples);
+      GST_WRITE_UINT32_LE (outdata + 12, wvh.block_index);
+      GST_WRITE_UINT32_LE (outdata + 16, block_samples);
+      GST_WRITE_UINT32_LE (outdata + 20, flags);
+      GST_WRITE_UINT32_LE (outdata + 24, crc);
+      outdata += 28;
+
+      memcpy (outdata, data, blocksize);

-        outpos = 0;
-        gst_buffer_map (newbuf, &outmap, GST_MAP_WRITE);
-        outdata = outmap.data;
-      } else {
-        gst_buffer_unmap (newbuf, &outmap);
-        out_size += sizeof (Wavpack4Header) + blocksize;
-        gst_buffer_set_size (newbuf, out_size);
-        gst_buffer_map (newbuf, &outmap, GST_MAP_WRITE);
-        outdata = outmap.data;
-      }
+      gst_buffer_unmap (newbuf, &outmap);
+      gst_adapter_push (adapter, newbuf);
+      newbuf = NULL;

-      outdata[outpos] = 'w';
-      outdata[outpos + 1] = 'v';
-      outdata[outpos + 2] = 'p';
-      outdata[outpos + 3] = 'k';
-      outpos += 4;
-
-      GST_WRITE_UINT32_LE (outdata + outpos,
-          blocksize + sizeof (Wavpack4Header) - 8);
-      GST_WRITE_UINT16_LE (outdata + outpos + 4, wvh.version);
-      GST_WRITE_UINT8 (outdata + outpos + 6, wvh.track_no);
-      GST_WRITE_UINT8 (outdata + outpos + 7, wvh.index_no);
-      GST_WRITE_UINT32_LE (outdata + outpos + 8, wvh.total_samples);
-      GST_WRITE_UINT32_LE (outdata + outpos + 12, wvh.block_index);
-      GST_WRITE_UINT32_LE (outdata + outpos + 16, block_samples);
-      GST_WRITE_UINT32_LE (outdata + outpos + 20, flags);
-      GST_WRITE_UINT32_LE (outdata + outpos + 24, crc);
-      outpos += 28;
-
-      memmove (outdata + outpos, data, blocksize);
-      outpos += blocksize;
       data += blocksize;
       size -= blocksize;
     }
     gst_buffer_unmap (*buf, &map);
-    gst_buffer_unref (*buf);

-    if (newbuf)
-      gst_buffer_unmap (newbuf, &outmap);
+    newbuf = gst_adapter_take_buffer (adapter, gst_adapter_available (adapter));
+    g_object_unref (adapter);

+    gst_buffer_copy_into (newbuf, *buf,
+        GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS, 0, -1);
+    gst_buffer_unref (*buf);
     *buf = newbuf;
+
     audiocontext->wvpk_block_index += block_samples;
   }

diff --git a/gst/matroska/matroska-ids.h b/gst/matroska/matroska-ids.h
index 429213f778063ba0063944ab64ad60373bbce5ee..8d4a685a910ec13100a3c3d156b2412d28ec0522 100644
--- a/gst/matroska/matroska-ids.h
+++ b/gst/matroska/matroska-ids.h
@@ -688,6 +688,8 @@ typedef struct _Wavpack4Header {
   guint32 crc;           /* crc for actual decoded data                    */
 } Wavpack4Header;

+#define WAVPACK4_HEADER_SIZE (32)
+
 typedef enum {
   GST_MATROSKA_TRACK_ENCODING_SCOPE_FRAME = (1<<0),
   GST_MATROSKA_TRACK_ENCODING_SCOPE_CODEC_DATA = (1<<1),


code:
Fix CVE-2021-3498:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-3498
https://gstreamer.freedesktop.org/security/sa-2021-0003.html

Patch copied from upstream source repository:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/commit/02174790726dd20a5c73ce2002189bf240ad4fe0?merge_request_iid=903

diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
index 4d0234743b8cf243b4521e56ef9027ba23b1b5d0..467815986c8c3d86fd8906a0d539b34f67d6693e 100644
--- a/gst/matroska/matroska-demux.c
+++ b/gst/matroska/matroska-demux.c
@@ -692,6 +692,8 @@ gst_matroska_demux_parse_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml,

   DEBUG_ELEMENT_START (demux, ebml, "TrackEntry");

+  *dest_context = NULL;
+
   /* start with the master */
   if ((ret = gst_ebml_read_master (ebml, &id)) != GST_FLOW_OK) {
     DEBUG_ELEMENT_STOP (demux, ebml, "TrackEntry", ret);


code:
Fix a broken test:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/803

Patches copied from upstream source repository:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/commit/2ce5909f3a0b0da3abb7b794215d6b8b72a3b7fa
https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/commit/f5310ce346180a717f091f2f09bcbb3ddfb15436

From 2ce5909f3a0b0da3abb7b794215d6b8b72a3b7fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= <tim@centricular.com>
Date: Thu, 12 Nov 2020 23:38:21 +0000
Subject: [PATCH 1/2] tests: qtdemux: fix crash on 32-bit architectures

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/803

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/815>
---
 tests/check/elements/qtdemux.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tests/check/elements/qtdemux.c b/tests/check/elements/qtdemux.c
index 5271c6576..0c748278b 100644
--- a/tests/check/elements/qtdemux.c
+++ b/tests/check/elements/qtdemux.c
@@ -797,9 +797,10 @@ GST_START_TEST (test_qtdemux_pad_names)
       "protection-system", G_TYPE_STRING,
       "9a04f079-9840-4286-ab92-e65be0885f95", NULL);
   caps =
-      gst_caps_new_simple ("video/quicktime", "variant", G_TYPE_STRING,
-      "mss-fragmented", "timesacle", G_TYPE_UINT64, 10000000, "media-caps",
-      GST_TYPE_CAPS, mediacaps, NULL);
+      gst_caps_new_simple ("video/quicktime",
+      "variant", G_TYPE_STRING, "mss-fragmented",
+      "timesacle", G_TYPE_UINT64, G_GUINT64_CONSTANT (10000000),
+      "media-caps", GST_TYPE_CAPS, mediacaps, NULL);

   /* Send segment event* */
   event = gst_event_new_caps (caps);
@@ -852,9 +853,10 @@ GST_START_TEST (test_qtdemux_pad_names)
       "protection-system", G_TYPE_STRING,
       "9a04f079-9840-4286-ab92-e65be0885f95", NULL);
   caps =
-      gst_caps_new_simple ("video/quicktime", "variant", G_TYPE_STRING,
-      "mss-fragmented", "timesacle", G_TYPE_UINT64, 10000000, "media-caps",
-      GST_TYPE_CAPS, mediacaps, NULL);
+      gst_caps_new_simple ("video/quicktime",
+      "variant", G_TYPE_STRING, "mss-fragmented",
+      "timesacle", G_TYPE_UINT64, G_GUINT64_CONSTANT (10000000),
+      "media-caps", GST_TYPE_CAPS, mediacaps, NULL);

   /* Send segment event* */
   event = gst_event_new_caps (caps);
--
2.30.0

From f5310ce346180a717f091f2f09bcbb3ddfb15436 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= <tim@centricular.com>
Date: Thu, 12 Nov 2020 23:39:21 +0000
Subject: [PATCH 2/2] tests: qtdemux: fix typo in caps field

timesacle -> timescale

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/815>
---
 tests/check/elements/qtdemux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/check/elements/qtdemux.c b/tests/check/elements/qtdemux.c
index 0c748278b..4a14c45c0 100644
--- a/tests/check/elements/qtdemux.c
+++ b/tests/check/elements/qtdemux.c
@@ -799,7 +799,7 @@ GST_START_TEST (test_qtdemux_pad_names)
   caps =
       gst_caps_new_simple ("video/quicktime",
       "variant", G_TYPE_STRING, "mss-fragmented",
-      "timesacle", G_TYPE_UINT64, G_GUINT64_CONSTANT (10000000),
+      "timescale", G_TYPE_UINT64, G_GUINT64_CONSTANT (10000000),
       "media-caps", GST_TYPE_CAPS, mediacaps, NULL);

   /* Send segment event* */
@@ -855,7 +855,7 @@ GST_START_TEST (test_qtdemux_pad_names)
   caps =
       gst_caps_new_simple ("video/quicktime",
       "variant", G_TYPE_STRING, "mss-fragmented",
-      "timesacle", G_TYPE_UINT64, G_GUINT64_CONSTANT (10000000),
+      "timescale", G_TYPE_UINT64, G_GUINT64_CONSTANT (10000000),
       "media-caps", GST_TYPE_CAPS, mediacaps, NULL);

   /* Send segment event* */
--
2.30.0


code:
Fix out of bounds reads when parsing audio and video packets:

https://security-tracker.debian.org/tracker/TEMP-0000000-4DAA44
https://gitlab.freedesktop.org/gstreamer/gst-plugins-ugly/-/issues/37

Patch copied from upstream source repository:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-ugly/-/commit/3aba7d1e625554b2407bc77b3d09b4928b937d5f
From 3aba7d1e625554b2407bc77b3d09b4928b937d5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
Date: Wed, 3 Mar 2021 11:05:14 +0200
Subject: [PATCH] rmdemux: Make sure we have enough data available when parsing
 audio/video packets

Otherwise there will be out-of-bounds reads and potential crashes.

Thanks to Natalie Silvanovich for reporting.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-ugly/-/issues/37

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-ugly/-/merge_requests/74>
---
 gst/realmedia/rmdemux.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gst/realmedia/rmdemux.c b/gst/realmedia/rmdemux.c
index 6cc659a1..68b0736b 100644
--- a/gst/realmedia/rmdemux.c
+++ b/gst/realmedia/rmdemux.c
@@ -2223,6 +2223,9 @@ gst_rmdemux_parse_video_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,

   gst_buffer_map (in, &map, GST_MAP_READ);

+  if (map.size < offset)
+    goto not_enough_data;
+
   data = map.data + offset;
   size = map.size - offset;

@@ -2289,6 +2292,9 @@ gst_rmdemux_parse_video_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
     }
     GST_DEBUG_OBJECT (rmdemux, "fragment size %d", fragment_size);

+    if (map.size < (data - map.data) + fragment_size)
+      goto not_enough_data;
+
     /* get the fragment */
     fragment =
         gst_buffer_copy_region (in, GST_BUFFER_COPY_ALL, data - map.data,
@@ -2437,6 +2443,9 @@ gst_rmdemux_parse_audio_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
   GstFlowReturn ret;
   GstBuffer *buffer;

+  if (gst_buffer_get_size (in) < offset)
+    goto not_enough_data;
+
   buffer = gst_buffer_copy_region (in, GST_BUFFER_COPY_MEMORY, offset, -1);

   if (rmdemux->first_ts != -1 && timestamp > rmdemux->first_ts)
@@ -2467,9 +2476,19 @@ gst_rmdemux_parse_audio_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
     ret = gst_pad_push (stream->pad, buffer);
   }

+done:
   gst_buffer_unref (in);

   return ret;
+
+  /* ERRORS */
+not_enough_data:
+  {
+    GST_ELEMENT_WARNING (rmdemux, STREAM, DECODE, ("Skipping bad packet."),
+        (NULL));
+    ret = GST_FLOW_OK;
+    goto done;
+  }
 }

 static GstFlowReturn
@@ -2490,6 +2509,9 @@ gst_rmdemux_parse_packet (GstRMDemux * rmdemux, GstBuffer * in, guint16 version)
   data = map.data;
   size = map.size;

+  if (size < 4 + 6 + 1 + 2)
+    goto not_enough_data;
+
   /* stream number */
   id = RMDEMUX_GUINT16_GET (data);

@@ -2525,6 +2547,9 @@ gst_rmdemux_parse_packet (GstRMDemux * rmdemux, GstBuffer * in, guint16 version)

   /* version 1 has an extra byte */
   if (version == 1) {
+    if (size < 1)
+      goto not_enough_data;
+
     data += 1;
     size -= 1;
   }
@@ -2596,6 +2621,16 @@ unknown_stream:
     gst_buffer_unref (in);
     return GST_FLOW_OK;
   }
+
+  /* ERRORS */
+not_enough_data:
+  {
+    GST_ELEMENT_WARNING (rmdemux, STREAM, DECODE, ("Skipping bad packet."),
+        (NULL));
+    gst_buffer_unmap (in, &map);
+    gst_buffer_unref (in);
+    return GST_FLOW_OK;
+  }
 }

 gboolean
--
2.31.1


code:
This patch replaces the environment variable "GTK_IM_MODULE" with
"GUIX_GTK2_IM_MODULE_FILE" to prevent this version of GTK+ from loading input
method modules for other major versions of GTK+.

--- gtk+-2.24.30/gtk/gtkrc.c	2016-08-21 22:40:22.339660438 +0200
+++ gtk+-2.24.30/gtk/gtkrc.c	2016-08-23 10:11:11.080822710 +0200
@@ -439,7 +439,7 @@
 gchar *
 gtk_rc_get_im_module_file (void)
 {
-  const gchar *var = g_getenv ("GTK_IM_MODULE_FILE");
+  const gchar *var = g_getenv ("GUIX_GTK2_IM_MODULE_FILE");
   gchar *result = NULL;

   if (var)


code:
This patch makes GTK+ look for additional modules in a list of directories
specified by the environment variable "GUIX_GTK2_PATH".  This can be used
instead of "GTK_PATH" to make GTK+ find modules that are incompatible with
other major versions of GTK+.

--- a/gtk/gtkmodules.c	2014-09-29 22:02:17.000000000 +0200
+++ b/gtk/gtkmodules.c	2015-12-02 18:41:53.306396938 +0100
@@ -55,6 +55,7 @@
 get_module_path (void)
 {
   const gchar *module_path_env;
+  const gchar *module_guix_gtk2_path_env;
   const gchar *exe_prefix;
   const gchar *home_dir;
   gchar *home_gtk_dir = NULL;
@@ -70,6 +71,7 @@
     home_gtk_dir = g_build_filename (home_dir, ".gtk-2.0", NULL);

   module_path_env = g_getenv ("GTK_PATH");
+  module_guix_gtk2_path_env = g_getenv ("GUIX_GTK2_PATH");
   exe_prefix = g_getenv ("GTK_EXE_PREFIX");

   if (exe_prefix)
@@ -77,9 +79,21 @@
   else
     default_dir = g_build_filename (GTK_LIBDIR, "gtk-2.0", NULL);

-  if (module_path_env && home_gtk_dir)
+  if (module_guix_gtk2_path_env && module_path_env && home_gtk_dir)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_guix_gtk2_path_env, module_path_env, home_gtk_dir, default_dir, NULL);
+  else if (module_guix_gtk2_path_env && home_gtk_dir)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_guix_gtk2_path_env, home_gtk_dir, default_dir, NULL);
+  else if (module_guix_gtk2_path_env && module_path_env)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_guix_gtk2_path_env, module_path_env, default_dir, NULL);
+  else if (module_path_env && home_gtk_dir)
     module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
 				module_path_env, home_gtk_dir, default_dir, NULL);
+  else if (module_guix_gtk2_path_env)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_guix_gtk2_path_env, default_dir, NULL);
   else if (module_path_env)
     module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
 				module_path_env, default_dir, NULL);


code:
From: Jookia <166291@gmail.com>
Subject: [PATCHv2] gtk: Patch GTK+ to look for themes in profiles.
To: guix-devel@gnu.org
Date: Sun, 13 Mar 2016 15:17:37 +1100
Url: https://lists.gnu.org/archive/html/guix-devel/2016-03/msg00492.html

diff -Naur gtk+-2.24.28.new/gtk/gtkrc.c gtk+-2.24.28/gtk/gtkrc.c
--- gtk+-2.24.28.new/gtk/gtkrc.c	2016-03-13 10:31:14.413644362 +1100
+++ gtk+-2.24.28/gtk/gtkrc.c	2016-03-13 12:51:34.723398423 +1100
@@ -808,6 +808,8 @@
   gchar *path = NULL;
   const gchar *home_dir;
   gchar *subpath;
+  const gchar * const *xdg_data_dirs;
+  gint i;

   if (type)
     subpath = g_strconcat ("gtk-2.0-", type,
@@ -830,6 +832,22 @@
     }

   if (!path)
+    {
+      xdg_data_dirs = g_get_system_data_dirs ();
+      for (i = 0; xdg_data_dirs[i]; i++)
+        {
+          path = g_build_filename (xdg_data_dirs[i], "themes", name, subpath, NULL);
+          if (g_file_test (path, G_FILE_TEST_EXISTS))
+            break;
+          else
+            {
+              g_free (path);
+              path = NULL;
+            }
+        }
+    }
+
+  if (!path)
     {
       gchar *theme_dir = gtk_rc_get_theme_dir ();
       path = g_build_filename (theme_dir, name, subpath, NULL);


code:
This patch replaces the environment variable "GTK_IM_MODULE" with
"GUIX_GTK3_IM_MODULE_FILE" to prevent this version of GTK+ from loading input
method modules for other major versions of GTK+.

--- gtk+-3.20.3/gtk/deprecated/gtkrc.c	2016-08-21 22:40:48.168437905 +0200
+++ gtk+-3.20.3/gtk/deprecated/gtkrc.c	2016-08-23 10:12:09.097070097 +0200
@@ -768,7 +768,7 @@
 gchar *
 gtk_rc_get_im_module_file (void)
 {
-  const gchar *var = g_getenv ("GTK_IM_MODULE_FILE");
+  const gchar *var = g_getenv ("GUIX_GTK3_IM_MODULE_FILE");
   gchar *result = NULL;

   if (var)


code:
This patch makes GTK+ look for additional modules in a list of directories
specified by the environment variable "GUIX_GTK3_PATH".  This can be used
instead of "GTK_PATH" to make GTK+ find modules that are incompatible with
other major versions of GTK+.

--- a/gtk/gtkmodules.c	2015-09-20 20:09:05.060590217 +0200
+++ b/gtk/gtkmodules.c	2015-09-20 20:10:33.423124833 +0200
@@ -52,6 +52,7 @@
 get_module_path (void)
 {
   const gchar *module_path_env;
+  const gchar *module_guix_gtk3_path_env;
   const gchar *exe_prefix;
   gchar *module_path;
   gchar *default_dir;
@@ -61,6 +62,7 @@
     return result;

   module_path_env = g_getenv ("GTK_PATH");
+  module_guix_gtk3_path_env = g_getenv ("GUIX_GTK3_PATH");
   exe_prefix = g_getenv ("GTK_EXE_PREFIX");

   if (exe_prefix)
@@ -68,7 +70,13 @@
   else
     default_dir = g_build_filename (_gtk_get_libdir (), "gtk-3.0", NULL);

-  if (module_path_env)
+  if (module_guix_gtk3_path_env && module_path_env)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_guix_gtk3_path_env, module_path_env, default_dir, NULL);
+  else if (module_guix_gtk3_path_env)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_guix_gtk3_path_env, default_dir, NULL);
+  else if (module_path_env)
     module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
 				module_path_env, default_dir, NULL);
   else


code:
Having DISABLE_DEPRECATED flags set in the distribution breaks
building with libraries later than those which the maintainer
happened to have installed.  This patch removes them.

diff -r -U 3 a/gtk/Makefile.am b/gtk/Makefile.am
--- a/gtk/Makefile.am	2003-05-09 15:55:05.000000000 +0200
+++ b/gtk/Makefile.am	2013-12-26 15:06:38.000000000 +0100
@@ -36,11 +36,7 @@
 	-I$(top_srcdir)			\
 	-I$(top_builddir)/gdk		\
 	$(GTKGLEXT_DEBUG_FLAGS)		\
-	$(GTKGLEXT_DEP_CFLAGS)		\
-	-DG_DISABLE_DEPRECATED		\
-	-DGDK_DISABLE_DEPRECATED	\
-	-DGDK_PIXBUF_DISABLE_DEPRECATED	\
-	-DGTK_DISABLE_DEPRECATED
+	$(GTKGLEXT_DEP_CFLAGS)

 common_ldflags = \
 	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) 	\
diff -r -U 3 a/gtk/Makefile.in b/gtk/Makefile.in
--- a/gtk/Makefile.in	2006-02-05 04:17:42.000000000 +0100
+++ b/gtk/Makefile.in	2013-12-26 15:07:00.000000000 +0100
@@ -234,11 +234,7 @@
 	-I$(top_srcdir)			\
 	-I$(top_builddir)/gdk		\
 	$(GTKGLEXT_DEBUG_FLAGS)		\
-	$(GTKGLEXT_DEP_CFLAGS)		\
-	-DG_DISABLE_DEPRECATED		\
-	-DGDK_DISABLE_DEPRECATED	\
-	-DGDK_PIXBUF_DISABLE_DEPRECATED	\
-	-DGTK_DISABLE_DEPRECATED
+	$(GTKGLEXT_DEP_CFLAGS)

 common_ldflags = \


code:
From fc401acb15f15d487c942437b6fb429289dd3c67 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Fri, 31 May 2019 13:22:25 +0200
Subject: [PATCH] Add installation directory as a default directory.

In Guix, this library is installed in a separate directory in the store,
and it's typically not installed system-wide in a fixed directory. Add
the store path to the set of default directories so dependents can find
default langs and source highlighting scheme.
---
 gtksourceview/gtksourceview-utils.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gtksourceview/gtksourceview-utils.c b/gtksourceview/gtksourceview-utils.c
index 6f06bab..c3467d5 100644
--- a/gtksourceview/gtksourceview-utils.c
+++ b/gtksourceview/gtksourceview-utils.c
@@ -66,6 +66,12 @@ _gtk_source_view_get_default_dirs (const char *basename,
 							 basename,
 							 NULL));

+    /* installed dir */
+    g_ptr_array_add (dirs, g_build_filename (DATADIR,
+						 SOURCEVIEW_DIR,
+						 basename,
+						 NULL));
+
 	g_ptr_array_add (dirs, NULL);

 	return (gchar**) g_ptr_array_free (dirs, FALSE);
--
2.21.0


code:
Fix doc snarfing with GCC 4.5+.
From <http://git.savannah.gnu.org/cgit/guile.git/commit/?h=branch_release-1-8&id=aac41d28358cea594bb30f6e547afb82bb6004a6>.

diff --git a/scripts/snarf-check-and-output-texi b/scripts/snarf-check-and-output-texi
index ea33e17..8cd42e8 100755
--- a/scripts/snarf-check-and-output-texi
+++ b/scripts/snarf-check-and-output-texi
@@ -267,6 +267,17 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
       (set! *file* file)
       (set! *line* line))

+     ;; newer gccs like to throw around more location markers into the
+     ;; preprocessed source; these (hash . hash) bits are what they translate to
+     ;; in snarfy terms.
+     (('location ('string . file) ('int . line) ('hash . 'hash))
+      (set! *file* file)
+      (set! *line* line))
+
+     (('location ('hash . 'hash) ('string . file) ('int . line) ('hash . 'hash))
+      (set! *file* file)
+      (set! *line* line))
+
      (('arglist rest ...)
       (set! *args* (do-arglist rest)))


code:
This hack makes Guile default to UTF-8.  This avoids calls to
`iconv_open'; `iconv_open' tries to open shared objects that aren't
available during bootstrap, so using UTF-8 avoids that (and UTF-8 has
built-in conversions in glibc, too.)

diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index 0ac5ea6a6..f73301e2f 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -1931,7 +1931,7 @@ utf_encoding_name (char *name, size_t utf_width, SCM endianness)
   if (scm_i_is_narrow_string (str))                                     \
     {                                                                   \
       err = mem_iconveh (scm_i_string_chars (str), c_strlen,            \
-                         "ISO-8859-1", c_utf_name,                      \
+                         "UTF-8", c_utf_name,                      \
                          iconveh_question_mark, NULL,                   \
                          &c_utf, &c_utf_len);                           \
       if (SCM_UNLIKELY (err))                                           \
diff --git a/libguile/ports.c b/libguile/ports.c
index 45e62f4e4..42012f3aa 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -974,7 +974,9 @@ canonicalize_encoding (const char *enc)
   char *ret;
   int i;

-  if (!enc || encoding_matches (enc, sym_ISO_8859_1))
+  if (enc == NULL)
+    return sym_UTF_8;
+  if (encoding_matches (enc, sym_ISO_8859_1))
     return sym_ISO_8859_1;
   if (encoding_matches (enc, sym_UTF_8))
     return sym_UTF_8;
@@ -4198,7 +4200,7 @@ scm_init_ports (void)
     scm_c_define ("%default-port-conversion-strategy",
                   scm_make_fluid_with_default (sym_substitute));
   /* Use the locale as the default port encoding.  */
-  scm_i_set_default_port_encoding (locale_charset ());
+  scm_i_set_default_port_encoding ("UTF-8");

   scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION,
                             "scm_init_ice_9_ports",
diff --git a/libguile/strings.c b/libguile/strings.c
index 056b4c99f..63a6c050d 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -1579,7 +1579,7 @@ scm_i_default_string_failed_conversion_handler (void)
 SCM
 scm_from_locale_stringn (const char *str, size_t len)
 {
-  return scm_from_stringn (str, len, locale_charset (),
+  return scm_from_stringn (str, len, "UTF-8",
                            scm_i_default_string_failed_conversion_handler ());
 }

@@ -1907,7 +1907,7 @@ char *
 scm_to_locale_stringn (SCM str, size_t *lenp)
 {
   return scm_to_stringn (str, lenp,
-                         locale_charset (),
+                         "UTF-8",
                          scm_i_default_string_failed_conversion_handler ());
 }

@@ -2195,7 +2195,7 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
     scm_wrong_type_arg_msg (NULL, 0, str, "string");

   if (encoding == NULL)
-    encoding = "ISO-8859-1";
+    encoding = "UTF-8";

   if (c_strcasecmp (encoding, "UTF-8") == 0)
     /* This is the most common case--e.g., when calling libc bindings
@@ -2247,7 +2247,7 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
   if (scm_i_is_narrow_string (str))
     {
       ret = mem_iconveh (scm_i_string_chars (str), ilen,
-                         "ISO-8859-1", encoding,
+                         "UTF-8", encoding,
                          (enum iconv_ilseq_handler) handler, NULL,
                          &buf, &len);


code:
Skip 'test-out-of-memory', which is unreliable in Guile 2.2.4:

  https://bugs.gnu.org/34155

--- a/test-suite/standalone/Makefile.in	1969-12-31 19:00:00.000000000 -0500
+++ b/test-suite/standalone/Makefile.in	2019-05-27 16:44:32.302355990 -0400
@@ -103,7 +103,7 @@
 	test-scm-c-bind-keyword-arguments$(EXEEXT) \
 	test-srfi-4$(EXEEXT) $(am__append_6) $(am__EXEEXT_1) \
 	test-smob-mark$(EXEEXT) test-smob-mark-race$(EXEEXT) \
-	test-stack-overflow test-out-of-memory
+	test-stack-overflow
 check_PROGRAMS = test-num2integral$(EXEEXT) test-round$(EXEEXT) \
 	test-foreign-object-c$(EXEEXT) test-list$(EXEEXT) \
 	test-unwind$(EXEEXT) test-conversion$(EXEEXT) \
@@ -1938,8 +1938,7 @@
 	test-command-line-encoding test-command-line-encoding2 \
 	test-language test-guild-compile $(am__append_3) \
 	test-foreign-object-scm test-fast-slot-ref test-mb-regexp \
-	test-use-srfi $(am__append_5) test-stack-overflow \
-	test-out-of-memory
+	test-use-srfi $(am__append_5) test-stack-overflow
 BUILT_SOURCES = $(am__append_2)
 EXTRA_DIST = test-import-order-a.scm test-import-order-b.scm \
 	test-import-order-c.scm test-import-order-d.scm \


code:
Skip 'test-stack-overflow' that crashes when using QEMU transparent emulation.

--- a/test-suite/standalone/Makefile.in	1970-01-01 01:00:01.000000000 +0100
+++ b/test-suite/standalone/Makefile.in	2021-01-11 10:59:31.606269449 +0100
@@ -102,8 +102,7 @@
 	test-scm-to-latin1-string$(EXEEXT) test-scm-values$(EXEEXT) \
 	test-scm-c-bind-keyword-arguments$(EXEEXT) \
 	test-srfi-4$(EXEEXT) $(am__append_6) $(am__EXEEXT_1) \
-	test-smob-mark$(EXEEXT) test-smob-mark-race$(EXEEXT) \
-	test-stack-overflow
+	test-smob-mark$(EXEEXT) test-smob-mark-race$(EXEEXT)
 check_PROGRAMS = test-num2integral$(EXEEXT) test-round$(EXEEXT) \
 	test-foreign-object-c$(EXEEXT) test-list$(EXEEXT) \
 	test-unwind$(EXEEXT) test-conversion$(EXEEXT) \
@@ -1938,7 +1937,7 @@
 	test-command-line-encoding test-command-line-encoding2 \
 	test-language test-guild-compile $(am__append_3) \
 	test-foreign-object-scm test-fast-slot-ref test-mb-regexp \
-	test-use-srfi $(am__append_5) test-stack-overflow
+	test-use-srfi $(am__append_5)
 BUILT_SOURCES = $(am__append_2)
 EXTRA_DIST = test-import-order-a.scm test-import-order-b.scm \
 	test-import-order-c.scm test-import-order-d.scm \


code:
This patch adds bindings to Linux syscalls for which glibc has symbols.

Using the FFI would have been nice, but that's not an option when using
a statically-linked Guile in an initrd that doesn't have libc.so around.

diff --git a/libguile/posix.c b/libguile/posix.c
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -2375,6 +2375,336 @@ scm_init_popen (void)
 }
 #endif /* HAVE_START_CHILD */

+
+/* Linux! */
+#ifdef __linux__
+
+#include <sys/mount.h>
+#include <sys/syscall.h>
+
+#include "libguile/foreign.h"
+#include "libguile/bytevectors.h"
+#include <libguile/variable.h>
+
+SCM_DEFINE (scm_mount, "mount", 3, 2, 0,
+	    (SCM source, SCM target, SCM type, SCM flags, SCM data),
+	    "Mount file system of @var{type} specified by @var{source} "
+	    "on @var{target}.")
+#define FUNC_NAME s_scm_mount
+{
+  int err;
+  char *c_source, *c_target, *c_type, *c_data;
+  unsigned long c_flags;
+
+  c_source = scm_to_locale_string (source);
+  c_target = scm_to_locale_string (target);
+  c_type = scm_to_locale_string (type);
+  c_flags = SCM_UNBNDP (flags) ? 0 : scm_to_ulong (flags);
+
+  if (SCM_UNBNDP (data) || scm_is_false (data))
+    c_data = NULL;
+  else
+    c_data = scm_to_locale_string (data);
+
+  err = mount (c_source, c_target, c_type, c_flags, c_data);
+  if (err != 0)
+    err = errno;
+
+  free (c_source);
+  free (c_target);
+  free (c_type);
+
+  if (c_data != NULL)
+    free (c_data);
+
+  if (err != 0)
+    {
+      errno = err;
+      SCM_SYSERROR;
+    }
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_umount, "umount", 1, 0, 0,
+	    (SCM target),
+	    "Unmount the file system on @var{target}.")
+#define FUNC_NAME s_scm_umount
+{
+  int err;
+  char *c_target;
+
+  c_target = scm_to_locale_string (target);
+
+  err = umount (c_target);
+  if (err != 0)
+    err = errno;
+
+  free (c_target);
+
+  if (err != 0)
+    {
+      errno = err;
+      SCM_SYSERROR;
+    }
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+/* Linux's module installation syscall.  See `kernel/module.c' in Linux;
+   the function itself is part of the GNU libc.
+
+   Load the LEN bytes at MODULE as a kernel module, with arguments from
+   ARGS, a space-separated list of options.  */
+extern long init_module (void *module, unsigned long len, const char *args);
+
+/* Load a kernel module from FD.  FLAGS must be a bitwise or of
+   MODULE_INIT_* constants.  The GNU libc doesn't provide a wrapper for
+   this one so we use 'syscall'.  */
+static int
+finit_module (int fd, const char *args, int flags)
+{
+  return syscall (SYS_finit_module, fd, args, flags);
+}
+
+
+SCM_DEFINE (scm_load_linux_module, "load-linux-module", 1, 1, 0,
+	    (SCM data, SCM options),
+	    "Load the Linux kernel module whose contents are in bytevector "
+	    "DATA (the contents of a @code{.ko} file), with the arguments "
+	    "from the OPTIONS string.")
+#define FUNC_NAME s_scm_load_linux_module
+{
+  long err;
+  void *c_data;
+  unsigned long c_len;
+  char *c_options;
+
+  SCM_VALIDATE_BYTEVECTOR (SCM_ARG1, data);
+
+  c_data = SCM_BYTEVECTOR_CONTENTS (data);
+  c_len = SCM_BYTEVECTOR_LENGTH (data);
+  c_options =
+    scm_to_locale_string (SCM_UNBNDP (options) ? scm_nullstr : options);
+
+  err = init_module (c_data, c_len, c_options);
+
+  free (c_options);
+
+  if (err != 0)
+    SCM_SYSERROR;
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_load_linux_module_fd, "load-linux-module/fd", 1, 2, 0,
+	    (SCM fd, SCM options, SCM flags),
+	    "Load the Linux kernel module from the file at FD, "
+	    "with the arguments from the OPTIONS string, and "
+            "optionally the given FLAGS.")
+#define FUNC_NAME s_scm_load_linux_module_fd
+{
+  long err;
+  int c_fd, c_flags;
+  char *c_options;
+
+  c_fd = scm_to_int (fd);
+  c_options =
+    scm_to_locale_string (SCM_UNBNDP (options) ? scm_nullstr : options);
+  c_flags = SCM_UNBNDP (flags) ? 0 : scm_to_int (flags);
+
+  err = finit_module (c_fd, c_options, c_flags);
+
+  free (c_options);
+
+  if (err != 0)
+    SCM_SYSERROR;
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+
+/* Rebooting, halting, and all that.  */
+
+#include <sys/reboot.h>
+
+SCM_VARIABLE_INIT (flag_RB_AUTOBOOT, "RB_AUTOBOOT",
+		   scm_from_int (RB_AUTOBOOT));
+SCM_VARIABLE_INIT (flag_RB_HALT_SYSTEM, "RB_HALT_SYSTEM",
+		   scm_from_int (RB_HALT_SYSTEM));
+SCM_VARIABLE_INIT (flag_RB_ENABLE_CAD, "RB_ENABLE_CAD",
+		   scm_from_int (RB_ENABLE_CAD));
+SCM_VARIABLE_INIT (flag_RB_DISABLE_CAD, "RB_DISABLE_CAD",
+		   scm_from_int (RB_DISABLE_CAD));
+SCM_VARIABLE_INIT (flag_RB_POWER_OFF, "RB_POWER_OFF",
+		   scm_from_int (RB_POWER_OFF));
+SCM_VARIABLE_INIT (flag_RB_SW_SUSPEND, "RB_SW_SUSPEND",
+		   scm_from_int (RB_SW_SUSPEND));
+SCM_VARIABLE_INIT (flag_RB_KEXEC, "RB_KEXEC",
+		   scm_from_int (RB_KEXEC));
+
+SCM_DEFINE (scm_reboot, "reboot", 0, 1, 0,
+	    (SCM command),
+	    "Reboot the system.  @var{command} must be one of the @code{RB_} "
+	    "constants; if omitted, @var{RB_AUTOBOOT} is used, thus "
+	    "performing a hard reset.")
+#define FUNC_NAME s_scm_reboot
+{
+  int c_command;
+
+  if (SCM_UNBNDP (command))
+    c_command = RB_AUTOBOOT;
+  else
+    c_command = scm_to_int (command);
+
+  reboot (c_command);
+
+  return SCM_UNSPECIFIED;			  /* likely unreached */
+}
+#undef FUNC_NAME
+
+/* Linux network interfaces.  See <linux/if.h>.  */
+
+#include <linux/if.h>
+#include <linux/sockios.h>
+#include "libguile/socket.h"
+
+SCM_VARIABLE_INIT (flag_IFF_UP, "IFF_UP",
+		   scm_from_int (IFF_UP));
+SCM_VARIABLE_INIT (flag_IFF_BROADCAST, "IFF_BROADCAST",
+		   scm_from_int (IFF_BROADCAST));
+SCM_VARIABLE_INIT (flag_IFF_DEBUG, "IFF_DEBUG",
+		   scm_from_int (IFF_DEBUG));
+SCM_VARIABLE_INIT (flag_IFF_LOOPBACK, "IFF_LOOPBACK",
+		   scm_from_int (IFF_LOOPBACK));
+SCM_VARIABLE_INIT (flag_IFF_POINTOPOINT, "IFF_POINTOPOINT",
+		   scm_from_int (IFF_POINTOPOINT));
+SCM_VARIABLE_INIT (flag_IFF_NOTRAILERS, "IFF_NOTRAILERS",
+		   scm_from_int (IFF_NOTRAILERS));
+SCM_VARIABLE_INIT (flag_IFF_RUNNING, "IFF_RUNNING",
+		   scm_from_int (IFF_RUNNING));
+SCM_VARIABLE_INIT (flag_IFF_NOARP, "IFF_NOARP",
+		   scm_from_int (IFF_NOARP));
+SCM_VARIABLE_INIT (flag_IFF_PROMISC, "IFF_PROMISC",
+		   scm_from_int (IFF_PROMISC));
+SCM_VARIABLE_INIT (flag_IFF_ALLMULTI, "IFF_ALLMULTI",
+		   scm_from_int (IFF_ALLMULTI));
+
+SCM_DEFINE (scm_set_network_interface_address, "set-network-interface-address",
+	    3, 0, 0,
+	    (SCM socket, SCM name, SCM address),
+	    "Configure network interface @var{name}.")
+#define FUNC_NAME s_scm_set_network_interface_address
+{
+  char *c_name;
+  struct ifreq ifr;
+  struct sockaddr *c_address;
+  size_t sa_len;
+  int fd, err;
+
+  socket = SCM_COERCE_OUTPORT (socket);
+  SCM_VALIDATE_OPFPORT (1, socket);
+  fd = SCM_FPORT_FDES (socket);
+
+  memset (&ifr, 0, sizeof ifr);
+  c_name = scm_to_locale_string (name);
+  c_address = scm_to_sockaddr (address, &sa_len);
+
+  strncpy (ifr.ifr_name, c_name, sizeof ifr.ifr_name - 1);
+  memcpy (&ifr.ifr_addr, c_address, sa_len);
+
+  err = ioctl (fd, SIOCSIFADDR, &ifr);
+  if (err != 0)
+    err = errno;
+
+  free (c_name);
+  free (c_address);
+
+  if (err != 0)
+    {
+      errno = err;
+      SCM_SYSERROR;
+    }
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_set_network_interface_flags, "set-network-interface-flags",
+	    3, 0, 0,
+	    (SCM socket, SCM name, SCM flags),
+	    "Change the flags of network interface @var{name} to "
+	    "@var{flags}.")
+#define FUNC_NAME s_scm_set_network_interface_flags
+{
+  struct ifreq ifr;
+  char *c_name;
+  int fd, err;
+
+  socket = SCM_COERCE_OUTPORT (socket);
+  SCM_VALIDATE_OPFPORT (1, socket);
+  fd = SCM_FPORT_FDES (socket);
+
+  memset (&ifr, 0, sizeof ifr);
+  c_name = scm_to_locale_string (name);
+  strncpy (ifr.ifr_name, c_name, sizeof ifr.ifr_name - 1);
+  ifr.ifr_flags = scm_to_short (flags);
+
+  err = ioctl (fd, SIOCSIFFLAGS, &ifr);
+  if (err != 0)
+    err = errno;
+
+  free (c_name);
+
+  if (err != 0)
+    {
+      errno = err;
+      SCM_SYSERROR;
+    }
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_network_interface_flags, "network-interface-flags",
+	    2, 0, 0,
+	    (SCM socket, SCM name),
+	    "Return the flags of network interface @var{name}.")
+#define FUNC_NAME s_scm_network_interface_flags
+{
+  struct ifreq ifr;
+  char *c_name;
+  int fd, err;
+
+  socket = SCM_COERCE_OUTPORT (socket);
+  SCM_VALIDATE_OPFPORT (1, socket);
+  fd = SCM_FPORT_FDES (socket);
+
+  memset (&ifr, 0, sizeof ifr);
+  c_name = scm_to_locale_string (name);
+  strncpy (ifr.ifr_name, c_name, sizeof ifr.ifr_name - 1);
+
+  err = ioctl (fd, SIOCGIFFLAGS, &ifr);
+  if (err != 0)
+    err = errno;
+
+  free (c_name);
+
+  if (err != 0)
+    {
+      errno = err;
+      SCM_SYSERROR;
+    }
+
+  return scm_from_short (ifr.ifr_flags);
+}
+#undef FUNC_NAME
+#endif
+
 void
 scm_init_posix ()
 {


code:
This patch changes Guile to use a default search path relative to the
location of the `guile' binary, allowing it to be relocated.

diff --git a/libguile/load.c b/libguile/load.c
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -27,6 +27,7 @@
 #include <stat-time.h>
 #include <string.h>
 #include <stdio.h>
+#include <libgen.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -334,6 +335,32 @@ scm_init_load_path ()
   SCM cpath = SCM_EOL;

 #ifdef SCM_LIBRARY_DIR
+  char *program, *bin_dir, *prefix, *module_dir, *ccache_dir;
+
+  /* Determine the source and compiled module directories at run-time,
+     relative to the executable's location.
+
+     Note: Use /proc/self/exe instead of argv[0] because the latter is
+     not necessarily an absolute, nor a valid file name.  */
+
+  program = scm_gc_malloc_pointerless (256, "string");
+  readlink ("/proc/self/exe", program, 256);
+
+  bin_dir = dirname (strdupa (program));
+
+  prefix = scm_gc_malloc_pointerless (strlen (bin_dir) + 4, "string");
+  strcpy (prefix, bin_dir);
+  strcat (prefix, "/..");
+  prefix = canonicalize_file_name (prefix);
+
+  module_dir = scm_gc_malloc_pointerless (strlen (prefix) + 50, "string");
+  strcpy (module_dir, prefix);
+  strcat (module_dir, "/share/guile/" SCM_EFFECTIVE_VERSION);
+
+  ccache_dir = scm_gc_malloc_pointerless (strlen (prefix) + 50, "string");
+  strcpy (ccache_dir, prefix);
+  strcat (ccache_dir, "/lib/guile/" SCM_EFFECTIVE_VERSION "/ccache");
+
   env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_PATH"));
   if (env && strcmp (env, "") == 0)
     /* special-case interpret system-path=="" as meaning no system path instead
@@ -342,10 +369,7 @@ scm_init_load_path ()
   else if (env)
     path = scm_parse_path (scm_from_locale_string (env), path);
   else
-    path = scm_list_4 (scm_from_utf8_string (SCM_LIBRARY_DIR),
-                       scm_from_utf8_string (SCM_SITE_DIR),
-                       scm_from_utf8_string (SCM_GLOBAL_SITE_DIR),
-                       scm_from_utf8_string (SCM_PKGDATA_DIR));
+    path = scm_list_1 (scm_from_locale_string (module_dir));

   env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_COMPILED_PATH"));
   if (env && strcmp (env, "") == 0)
@@ -355,8 +379,7 @@ scm_init_load_path ()
     cpath = scm_parse_path (scm_from_locale_string (env), cpath);
   else
     {
-      cpath = scm_list_2 (scm_from_utf8_string (SCM_CCACHE_DIR),
-                          scm_from_utf8_string (SCM_SITE_CCACHE_DIR));
+      cpath = scm_list_1 (scm_from_locale_string (ccache_dir));
     }

 #endif /* SCM_LIBRARY_DIR */


code:
This hack makes Guile default to UTF-8.  This avoids calls to
`iconv_open'; `iconv_open' tries to open shared objects that aren't
available during bootstrap, so using UTF-8 avoids that (and UTF-8 has
built-in conversions in glibc, too.)

diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index cf41f2f..facfb91 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -1887,7 +1887,7 @@ utf_encoding_name (char *name, size_t utf_width, SCM endianness)
   if (scm_i_is_narrow_string (str))                                     \
     {                                                                   \
       err = mem_iconveh (scm_i_string_chars (str), c_strlen,            \
-                         "ISO-8859-1", c_utf_name,                      \
+                         "UTF-8", c_utf_name,                      \
                          iconveh_question_mark, NULL,                   \
                          &c_utf, &c_utf_len);                           \
       if (SCM_UNLIKELY (err))                                           \
diff --git a/libguile/ports.c b/libguile/ports.c
index 301bc44..b0ea2e6 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -1750,7 +1750,7 @@ scm_ungetc (scm_t_wchar c, SCM port)
   if (pt->encoding != NULL)
     encoding = pt->encoding;
   else
-    encoding = "ISO-8859-1";
+    encoding = "UTF-8";

   len = sizeof (result_buf);
   result = u32_conv_to_encoding (encoding,
@@ -2212,7 +2212,7 @@ scm_i_set_port_encoding_x (SCM port, const char *encoding)
   pt = SCM_PTAB_ENTRY (port);

   if (encoding == NULL)
-    encoding = "ISO-8859-1";
+    encoding = "UTF-8";

   if (pt->encoding != encoding)
     pt->encoding = scm_gc_strdup (encoding, "port");
diff --git a/libguile/posix.c b/libguile/posix.c
index 4f8b8ac..fea7f74 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1740,7 +1740,7 @@ SCM_DEFINE (scm_setlocale, "setlocale", 1, 1, 0,
       SCM_SYSERROR;
     }

-  enc = locale_charset ();
+  enc = "UTF-8";

   /* Set the default encoding for new ports.  */
   scm_i_set_default_port_encoding (enc);
diff --git a/libguile/script.c b/libguile/script.c
index 83daf8a..083891e 100644
--- a/libguile/script.c
+++ b/libguile/script.c
@@ -387,7 +387,7 @@ locale_arguments_to_string_list (int argc, char **const argv)
   SCM lst;
   const char *encoding;

-  encoding = environ_locale_charset ();
+  encoding = "UTF-8";
   for (i = argc - 1, lst = SCM_EOL;
        i >= 0;
        i--)
diff --git a/libguile/strings.c b/libguile/strings.c
index 5d0db23..8266247 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -1576,7 +1576,7 @@ scm_from_locale_string (const char *str)
 SCM
 scm_from_locale_stringn (const char *str, size_t len)
 {
-  return scm_from_stringn (str, len, locale_charset (),
+  return scm_from_stringn (str, len, "UTF-8",
                            scm_i_default_port_conversion_handler ());
 }

@@ -1803,7 +1803,7 @@ char *
 scm_to_locale_stringn (SCM str, size_t *lenp)
 {
   return scm_to_stringn (str, lenp,
-                         locale_charset (),
+                         "UTF-8",
                          scm_i_default_port_conversion_handler ());
 }

@@ -2054,7 +2054,7 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
                         "string contains #\\nul character: ~S",
                         scm_list_1 (str));

-  if (scm_i_is_narrow_string (str) && (encoding == NULL))
+  if (scm_i_is_narrow_string (str))
     {
       /* If using native Latin-1 encoding, just copy the string
          contents.  */
@@ -2079,11 +2079,11 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
   len = 0;
   enc = encoding;
   if (enc == NULL)
-    enc = "ISO-8859-1";
+    enc = "UTF-8";
   if (scm_i_is_narrow_string (str))
     {
       ret = mem_iconveh (scm_i_string_chars (str), ilen,
-                         "ISO-8859-1", enc,
+                         "UTF-8", enc,
                          (enum iconv_ilseq_handler) handler, NULL,
                          &buf, &len);

--- guile-2.0.9/libguile/ports.c	2013-08-21 11:08:50.000000000 +0200
+++ guile-2.0.9/libguile/ports.c	2013-08-21 11:09:47.000000000 +0200
@@ -2512,7 +2512,7 @@ scm_i_port_iconv_descriptors (SCM port,
       const char *precise_encoding;

       if (!pt->encoding)
-        pt->encoding = "ISO-8859-1";
+        pt->encoding = "UTF-8";

       /* If the specified encoding is UTF-16 or UTF-32, then make
          that more precise by deciding what byte order to use. */


code:
Two patches here backporting fixes from Emacs master.

Upstream status: emailed first patch to latest committer, Robin Templeton
<robin@igalia.com>, no response.

From dfcb3b6ff318e47b84a28cfc43f50bec42fa3570 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Tue, 7 Nov 2017 18:48:03 +0100
Subject: [PATCH 1/2] backport: Port jpeg configuration to Solaris 10 with Sun
 C.

* configure.ac: Check for jpeglib 6b by trying to link it, instead
of relying on cpp magic that has problems in practice.  Check for
both jpeglib.h and jerror.h features.  Remove special case for
mingw32, which should no longer be needed (and if it were needed,
should now be addressable by hotwiring emacs_cv_jpeglib).
Fixes: bug#20332

    From fdf532b9c915ad9ba72155646d29d0f530fd72ec Mon Sep 17 00:00:00 2001
    From: Paul Eggert <address@hidden>
    Date: Wed, 15 Apr 2015 18:30:01 -0700
    Subject: [PATCH] Port jpeg configuration to Solaris 10 with Sun C.

    * configure.ac: Check for jpeglib 6b by trying to link it, instead
    of relying on cpp magic that has problems in practice.  Check for
    both jpeglib.h and jerror.h features.  Remove special case for
    mingw32, which should no longer be needed (and if it were needed,
    should now be addressable by hotwiring emacs_cv_jpeglib).
    Fixes: bug#20332
---
 configure.ac | 72 ++++++++++++++++++++++++++++--------------------------------
 1 file changed, 34 insertions(+), 38 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2445db4886..36fa8eb390 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3014,44 +3014,40 @@ AC_SUBST(LIBXPM)
 ### mingw32 doesn't use -ljpeg, since it loads the library dynamically.
 HAVE_JPEG=no
 LIBJPEG=
-if test "${opsys}" = "mingw32"; then
-  if test "${with_jpeg}" != "no"; then
-    dnl Checking for jpeglib.h can lose because of a redefinition of
-    dnl HAVE_STDLIB_H.
-    AC_CHECK_HEADER(jerror.h, HAVE_JPEG=yes, HAVE_JPEG=no)
-  fi
-  AH_TEMPLATE(HAVE_JPEG, [Define to 1 if you have the jpeg library (-ljpeg).])dnl
-  if test "${HAVE_JPEG}" = "yes"; then
-    AC_DEFINE(HAVE_JPEG)
-    AC_EGREP_CPP([version= *(6[2-9]|[7-9][0-9])],
-        [#include <jpeglib.h>
-	 version=JPEG_LIB_VERSION
-],
-        [AC_DEFINE(HAVE_JPEG)],
-        [AC_MSG_WARN([libjpeg found, but not version 6b or later])
-        HAVE_JPEG=no])
-  fi
-elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
-  if test "${with_jpeg}" != "no"; then
-    dnl Checking for jpeglib.h can lose because of a redefinition of
-    dnl  HAVE_STDLIB_H.
-    AC_CHECK_HEADER(jerror.h,
-      [AC_CHECK_LIB(jpeg, jpeg_destroy_compress, HAVE_JPEG=yes)])
-  fi
-
-  AH_TEMPLATE(HAVE_JPEG, [Define to 1 if you have the jpeg library (-ljpeg).])dnl
-  if test "${HAVE_JPEG}" = "yes"; then
-    AC_DEFINE(HAVE_JPEG)
-    AC_EGREP_CPP([version= *(6[2-9]|[7-9][0-9])],
-	[#include <jpeglib.h>
-	 version=JPEG_LIB_VERSION
-],
-	[AC_DEFINE(HAVE_JPEG)],
-	[AC_MSG_WARN([libjpeg found, but not version 6b or later])
-	HAVE_JPEG=no])
-  fi
-  if test "${HAVE_JPEG}" = "yes"; then
-    LIBJPEG=-ljpeg
+if test "${with_jpeg}" != "no"; then
+  AC_CACHE_CHECK([for jpeglib 6b or later],
+    [emacs_cv_jpeglib],
+    [OLD_LIBS=$LIBS
+     for emacs_cv_jpeglib in yes -ljpeg no; do
+       case $emacs_cv_jpeglib in
+	 yes) ;;
+         no) break;;
+	 *) LIBS="$LIBS $emacs_cv_jpeglib";;
+       esac
+       AC_LINK_IFELSE(
+	 [AC_LANG_PROGRAM(
+	    [[#undef HAVE_STDLIB_H /* Avoid config.h/jpeglib.h collision.  */
+	      #include <stdio.h> /* jpeglib.h needs FILE and size_t.  */
+	      #include <jpeglib.h>
+	      #include <jerror.h>
+	      char verify[JPEG_LIB_VERSION < 62 ? -1 : 1];
+	      struct jpeg_decompress_struct cinfo;
+	    ]],
+	    [[
+	      jpeg_create_decompress (&cinfo);
+	      WARNMS (&cinfo, JWRN_JPEG_EOF);
+	      jpeg_destroy_decompress (&cinfo);
+	    ]])],
+	 [emacs_link_ok=yes],
+	 [emacs_link_ok=no])
+       LIBS=$OLD_LIBS
+       test $emacs_link_ok = yes && break
+     done])
+  if test "$emacs_cv_jpeglib" != no; then
+    HAVE_JPEG=yes
+    AC_DEFINE([HAVE_JPEG], 1,
+      [Define to 1 if you have the jpeg library (typically -ljpeg).])
+    test "$emacs_cv_jpeglib" != yes && LIBJPEG=$emacs_cv_jpeglib
   fi
 fi
 AC_SUBST(LIBJPEG)
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

From f761b92d520b72954be28ad66eb82d1a96c785fb Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Wed, 8 Nov 2017 14:05:43 +0100
Subject: [PATCH 2/2] backport fix for #24065: calloc loop when compiling with
 -O2.

This patch fixes

    EMACSLOADPATH= '../src/bootstrap-emacs' -batch --no-site-file --no-site-lisp -l autoload \
       --eval "(setq generate-autoload-cookie \";;;###cal-autoload\")" \
       --eval "(setq generated-autoload-file (expand-file-name
    (unmsys--file-name
    \"../../git-checkout/lisp/calendar/cal-loaddefs.el\")))" \
       -f batch-update-autoloads ../../git-checkout/lisp/calendar
    make[2]: *** [Makefile:466: ../../git-checkout/lisp/calendar/cal-loaddefs.el] Segmentation fault

in gdb seen as

    in calloc (nmemb=<error reading variable: DWARF-2 expression error:Loop detected (257).>, size=size@entry=1) at gmalloc.c:1510

I did not find malloc-fixing commits from emacs master to cleanly
cherry-pick, so this patch replaces the relevant part in configure
(emacs 53da55b8cc45e76b836ebaadd23f46e92d25abce).

* configure.ac: backport system_malloc/hybrid_malloc detection.
---
 configure.ac | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 36fa8eb390..3cc1794f37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1966,7 +1966,25 @@ case "$opsys" in
   darwin|mingw32|sol2-10) system_malloc=yes ;;
 esac

+hybrid_malloc=
+system_malloc=yes
+
+test "$CANNOT_DUMP" = yes ||
+case "$opsys" in
+  ## darwin ld insists on the use of malloc routines in the System framework.
+  darwin | mingw32 | nacl | sol2-10) ;;
+  cygwin) hybrid_malloc=yes
+          system_malloc= ;;
+  *) test "$ac_cv_func_sbrk" = yes && system_malloc=$emacs_cv_sanitize_address;;
+esac
+
+if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \
+   && test "${UNEXEC_OBJ}" = unexelf.o; then
+  hybrid_malloc=yes
+fi
+
 GMALLOC_OBJ=
+HYBRID_MALLOC=
 if test "${system_malloc}" = "yes"; then
   AC_DEFINE([SYSTEM_MALLOC], 1,
     [Define to 1 to use the system memory allocator, even if it is not
@@ -1975,6 +1993,14 @@ if test "${system_malloc}" = "yes"; then
   GNU_MALLOC_reason="
     (The GNU allocators don't work with this system configuration.)"
   VMLIMIT_OBJ=
+elif test "$hybrid_malloc" = yes; then
+  AC_DEFINE(HYBRID_MALLOC, 1,
+    [Define to use gmalloc before dumping and the system malloc after.])
+  HYBRID_MALLOC=1
+  GNU_MALLOC=no
+  GNU_MALLOC_reason=" (only before dumping)"
+  GMALLOC_OBJ=gmalloc.o
+  VMLIMIT_OBJ=
 else
   test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
   VMLIMIT_OBJ=vm-limit.o
@@ -1993,10 +2019,11 @@ else
        of the main data segment.])
   fi
 fi
+AC_SUBST([HYBRID_MALLOC])
 AC_SUBST(GMALLOC_OBJ)
 AC_SUBST(VMLIMIT_OBJ)

-if test "$doug_lea_malloc" = "yes" ; then
+if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then
   if test "$GNU_MALLOC" = yes ; then
     GNU_MALLOC_reason="
       (Using Doug Lea's new malloc from the GNU C Library.)"
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com


code:
Fibers 1.0.0 has a bug in run-fibers in which peer schedulers aren't destroyed -
so if you had 4 cores, 1 would be destroyed when run-fibers returned, but the
other 3 would stay around.  Each scheduler uses 3 file descriptors, so for
machines with many cores, this resource leak adds up quickly - quickly enough
that the test suite can even fail because of it.

See https://github.com/wingo/fibers/issues/36.

This fixes that.  It should be safe to destroy the peer schedulers at the given
point because the threads that could be running them are all either dead or the
current thread.

As of May 21, 2020, this bug still existed in the 1.0.0 (latest) release and in
git master.
--- a/fibers.scm	2020-05-21 18:38:06.890690154 -0500
+++ b/fibers.scm	2020-05-21 18:38:56.395686693 -0500
@@ -137,5 +137,6 @@
              (%run-fibers scheduler hz finished? affinity))
            (lambda ()
              (stop-auxiliary-threads scheduler)))))
+      (for-each destroy-scheduler (scheduler-remote-peers scheduler))
       (destroy-scheduler scheduler)
       (apply values (atomic-box-ref ret))))))


code:
From 1da99396dc65993ba34ac0370ca5d6acda6a3322 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Sun, 18 Mar 2018 07:02:37 -0400
Subject: [PATCH] Add support for gdbm-1.14.

As of gdbm-1.14, 'gdbm_errno' no longer exists as a binary interface.
It has been replaced by 'gdbm_errno_location', a function that returns
int*.  We now use this new interface if it's available.
---
 gdbm.scm | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/gdbm.scm b/gdbm.scm
index b92992f..4d38cc3 100644
--- a/gdbm.scm
+++ b/gdbm.scm
@@ -17,6 +17,9 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.

+;; Modified by Mark H Weaver <mhw@netris.org> in March 2018 to support
+;; gdbm-1.14 with its new 'gdbm_errno_location' interface.
+
 (define-module (gdbm)
   #:use-module (system foreign)
   #:use-module (rnrs bytevectors)
@@ -151,10 +154,21 @@

 ;;; errors

-(define %errno (dynamic-pointer "gdbm_errno" libgdbm))
+(define %list-int
+  (list int))
+
+(define (dereference-int ptr)
+  (apply (lambda (errno) errno)
+         (parse-c-struct ptr %list-int)))
+
+(define %errno-location
+  (or (false-if-exception
+       (let ((func (dynamic-func "gdbm_errno_location" libgdbm)))
+         (pointer->procedure '* func '())))
+      (const (dynamic-pointer "gdbm_errno" libgdbm))))

 (define (gdbm-errno)
-  (pointer-address (dereference-pointer %errno)))
+  (dereference-int (%errno-location)))

 (define (gdbm-error)
   (error (pointer->string (%gdbm-strerror (gdbm-errno)))))
--
2.16.2


code:
This patch adds bindings to Linux syscalls for which glibc has symbols.

Using the FFI would have been nice, but that's not an option when using
a statically-linked Guile in an initrd that doesn't have libc.so around.

diff --git a/libguile/posix.c b/libguile/posix.c
index b0fcad5fd..1343186e3 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -2341,6 +2341,335 @@ scm_init_popen (void)
 }
 #endif /* HAVE_START_CHILD */

+
+/* Linux! */
+#ifdef __linux__
+
+#include <sys/mount.h>
+#include <sys/syscall.h>
+
+#include "libguile/foreign.h"
+#include "libguile/bytevectors.h"
+
+SCM_DEFINE (scm_mount, "mount", 3, 2, 0,
+	    (SCM source, SCM target, SCM type, SCM flags, SCM data),
+	    "Mount file system of @var{type} specified by @var{source} "
+	    "on @var{target}.")
+#define FUNC_NAME s_scm_mount
+{
+  int err;
+  char *c_source, *c_target, *c_type, *c_data;
+  unsigned long c_flags;
+
+  c_source = scm_to_locale_string (source);
+  c_target = scm_to_locale_string (target);
+  c_type = scm_to_locale_string (type);
+  c_flags = SCM_UNBNDP (flags) ? 0 : scm_to_ulong (flags);
+
+  if (SCM_UNBNDP (data) || scm_is_false (data))
+    c_data = NULL;
+  else
+    c_data = scm_to_locale_string (data);
+
+  err = mount (c_source, c_target, c_type, c_flags, c_data);
+  if (err != 0)
+    err = errno;
+
+  free (c_source);
+  free (c_target);
+  free (c_type);
+
+  if (c_data != NULL)
+    free (c_data);
+
+  if (err != 0)
+    {
+      errno = err;
+      SCM_SYSERROR;
+    }
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_umount, "umount", 1, 0, 0,
+	    (SCM target),
+	    "Unmount the file system on @var{target}.")
+#define FUNC_NAME s_scm_umount
+{
+  int err;
+  char *c_target;
+
+  c_target = scm_to_locale_string (target);
+
+  err = umount (c_target);
+  if (err != 0)
+    err = errno;
+
+  free (c_target);
+
+  if (err != 0)
+    {
+      errno = err;
+      SCM_SYSERROR;
+    }
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+/* Linux's module installation syscall.  See `kernel/module.c' in Linux;
+   the function itself is part of the GNU libc.
+
+   Load the LEN bytes at MODULE as a kernel module, with arguments from
+   ARGS, a space-separated list of options.  */
+extern long init_module (void *module, unsigned long len, const char *args);
+
+/* Load a kernel module from FD.  FLAGS must be a bitwise or of
+   MODULE_INIT_* constants.  The GNU libc doesn't provide a wrapper for
+   this one so we use 'syscall'.  */
+static int
+finit_module (int fd, const char *args, int flags)
+{
+  return syscall (SYS_finit_module, fd, args, flags);
+}
+
+
+SCM_DEFINE (scm_load_linux_module, "load-linux-module", 1, 1, 0,
+	    (SCM data, SCM options),
+	    "Load the Linux kernel module whose contents are in bytevector "
+	    "DATA (the contents of a @code{.ko} file), with the arguments "
+	    "from the OPTIONS string.")
+#define FUNC_NAME s_scm_load_linux_module
+{
+  long err;
+  void *c_data;
+  unsigned long c_len;
+  char *c_options;
+
+  SCM_VALIDATE_BYTEVECTOR (SCM_ARG1, data);
+
+  c_data = SCM_BYTEVECTOR_CONTENTS (data);
+  c_len = SCM_BYTEVECTOR_LENGTH (data);
+  c_options =
+    scm_to_locale_string (SCM_UNBNDP (options) ? scm_nullstr : options);
+
+  err = init_module (c_data, c_len, c_options);
+
+  free (c_options);
+
+  if (err != 0)
+    SCM_SYSERROR;
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_load_linux_module_fd, "load-linux-module/fd", 1, 2, 0,
+	    (SCM fd, SCM options, SCM flags),
+	    "Load the Linux kernel module from the file at FD, "
+	    "with the arguments from the OPTIONS string, and "
+            "optionally the given FLAGS.")
+#define FUNC_NAME s_scm_load_linux_module_fd
+{
+  long err;
+  int c_fd, c_flags;
+  char *c_options;
+
+  c_fd = scm_to_int (fd);
+  c_options =
+    scm_to_locale_string (SCM_UNBNDP (options) ? scm_nullstr : options);
+  c_flags = SCM_UNBNDP (flags) ? 0 : scm_to_int (flags);
+
+  err = finit_module (c_fd, c_options, c_flags);
+
+  free (c_options);
+
+  if (err != 0)
+    SCM_SYSERROR;
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+
+/* Rebooting, halting, and all that.  */
+
+#include <sys/reboot.h>
+
+SCM_VARIABLE_INIT (flag_RB_AUTOBOOT, "RB_AUTOBOOT",
+		   scm_from_int (RB_AUTOBOOT));
+SCM_VARIABLE_INIT (flag_RB_HALT_SYSTEM, "RB_HALT_SYSTEM",
+		   scm_from_int (RB_HALT_SYSTEM));
+SCM_VARIABLE_INIT (flag_RB_ENABLE_CAD, "RB_ENABLE_CAD",
+		   scm_from_int (RB_ENABLE_CAD));
+SCM_VARIABLE_INIT (flag_RB_DISABLE_CAD, "RB_DISABLE_CAD",
+		   scm_from_int (RB_DISABLE_CAD));
+SCM_VARIABLE_INIT (flag_RB_POWER_OFF, "RB_POWER_OFF",
+		   scm_from_int (RB_POWER_OFF));
+SCM_VARIABLE_INIT (flag_RB_SW_SUSPEND, "RB_SW_SUSPEND",
+		   scm_from_int (RB_SW_SUSPEND));
+SCM_VARIABLE_INIT (flag_RB_KEXEC, "RB_KEXEC",
+		   scm_from_int (RB_KEXEC));
+
+SCM_DEFINE (scm_reboot, "reboot", 0, 1, 0,
+	    (SCM command),
+	    "Reboot the system.  @var{command} must be one of the @code{RB_} "
+	    "constants; if omitted, @var{RB_AUTOBOOT} is used, thus "
+	    "performing a hard reset.")
+#define FUNC_NAME s_scm_reboot
+{
+  int c_command;
+
+  if (SCM_UNBNDP (command))
+    c_command = RB_AUTOBOOT;
+  else
+    c_command = scm_to_int (command);
+
+  reboot (c_command);
+
+  return SCM_UNSPECIFIED;			  /* likely unreached */
+}
+#undef FUNC_NAME
+
+/* Linux network interfaces.  See <linux/if.h>.  */
+
+#include <linux/if.h>
+#include <linux/sockios.h>
+#include "libguile/socket.h"
+
+SCM_VARIABLE_INIT (flag_IFF_UP, "IFF_UP",
+		   scm_from_int (IFF_UP));
+SCM_VARIABLE_INIT (flag_IFF_BROADCAST, "IFF_BROADCAST",
+		   scm_from_int (IFF_BROADCAST));
+SCM_VARIABLE_INIT (flag_IFF_DEBUG, "IFF_DEBUG",
+		   scm_from_int (IFF_DEBUG));
+SCM_VARIABLE_INIT (flag_IFF_LOOPBACK, "IFF_LOOPBACK",
+		   scm_from_int (IFF_LOOPBACK));
+SCM_VARIABLE_INIT (flag_IFF_POINTOPOINT, "IFF_POINTOPOINT",
+		   scm_from_int (IFF_POINTOPOINT));
+SCM_VARIABLE_INIT (flag_IFF_NOTRAILERS, "IFF_NOTRAILERS",
+		   scm_from_int (IFF_NOTRAILERS));
+SCM_VARIABLE_INIT (flag_IFF_RUNNING, "IFF_RUNNING",
+		   scm_from_int (IFF_RUNNING));
+SCM_VARIABLE_INIT (flag_IFF_NOARP, "IFF_NOARP",
+		   scm_from_int (IFF_NOARP));
+SCM_VARIABLE_INIT (flag_IFF_PROMISC, "IFF_PROMISC",
+		   scm_from_int (IFF_PROMISC));
+SCM_VARIABLE_INIT (flag_IFF_ALLMULTI, "IFF_ALLMULTI",
+		   scm_from_int (IFF_ALLMULTI));
+
+SCM_DEFINE (scm_set_network_interface_address, "set-network-interface-address",
+	    3, 0, 0,
+	    (SCM socket, SCM name, SCM address),
+	    "Configure network interface @var{name}.")
+#define FUNC_NAME s_scm_set_network_interface_address
+{
+  char *c_name;
+  struct ifreq ifr;
+  struct sockaddr *c_address;
+  size_t sa_len;
+  int fd, err;
+
+  socket = SCM_COERCE_OUTPORT (socket);
+  SCM_VALIDATE_OPFPORT (1, socket);
+  fd = SCM_FPORT_FDES (socket);
+
+  memset (&ifr, 0, sizeof ifr);
+  c_name = scm_to_locale_string (name);
+  c_address = scm_to_sockaddr (address, &sa_len);
+
+  strncpy (ifr.ifr_name, c_name, sizeof ifr.ifr_name - 1);
+  memcpy (&ifr.ifr_addr, c_address, sa_len);
+
+  err = ioctl (fd, SIOCSIFADDR, &ifr);
+  if (err != 0)
+    err = errno;
+
+  free (c_name);
+  free (c_address);
+
+  if (err != 0)
+    {
+      errno = err;
+      SCM_SYSERROR;
+    }
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_set_network_interface_flags, "set-network-interface-flags",
+	    3, 0, 0,
+	    (SCM socket, SCM name, SCM flags),
+	    "Change the flags of network interface @var{name} to "
+	    "@var{flags}.")
+#define FUNC_NAME s_scm_set_network_interface_flags
+{
+  struct ifreq ifr;
+  char *c_name;
+  int fd, err;
+
+  socket = SCM_COERCE_OUTPORT (socket);
+  SCM_VALIDATE_OPFPORT (1, socket);
+  fd = SCM_FPORT_FDES (socket);
+
+  memset (&ifr, 0, sizeof ifr);
+  c_name = scm_to_locale_string (name);
+  strncpy (ifr.ifr_name, c_name, sizeof ifr.ifr_name - 1);
+  ifr.ifr_flags = scm_to_short (flags);
+
+  err = ioctl (fd, SIOCSIFFLAGS, &ifr);
+  if (err != 0)
+    err = errno;
+
+  free (c_name);
+
+  if (err != 0)
+    {
+      errno = err;
+      SCM_SYSERROR;
+    }
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_network_interface_flags, "network-interface-flags",
+	    2, 0, 0,
+	    (SCM socket, SCM name),
+	    "Return the flags of network interface @var{name}.")
+#define FUNC_NAME s_scm_network_interface_flags
+{
+  struct ifreq ifr;
+  char *c_name;
+  int fd, err;
+
+  socket = SCM_COERCE_OUTPORT (socket);
+  SCM_VALIDATE_OPFPORT (1, socket);
+  fd = SCM_FPORT_FDES (socket);
+
+  memset (&ifr, 0, sizeof ifr);
+  c_name = scm_to_locale_string (name);
+  strncpy (ifr.ifr_name, c_name, sizeof ifr.ifr_name - 1);
+
+  err = ioctl (fd, SIOCGIFFLAGS, &ifr);
+  if (err != 0)
+    err = errno;
+
+  free (c_name);
+
+  if (err != 0)
+    {
+      errno = err;
+      SCM_SYSERROR;
+    }
+
+  return scm_from_short (ifr.ifr_flags);
+}
+#undef FUNC_NAME
+#endif
+
 void
 scm_init_posix ()
 {


code:
The tests/org-mode.scm tests expects 'jpl-outline-es' to be read as UTF-8.

--- guile-present-0.3.0/tests/org-mode.scm	2014-09-23 22:29:51.426705753 +0200
+++ guile-present-0.3.0/tests/org-mode.scm	2014-09-23 22:30:09.634705548 +0200
@@ -194,9 +194,10 @@
                "(Just another hacker)"
                "wingo@fluendo.com")
             (p "Julien Moutte, CEO" "julien@fluendo.com")))
+   (with-fluids ((%default-port-encoding "UTF-8"))
    (call-with-input-file
        (in-vicinity *top-srcdir* "tests/jpl-outline-es")
-     org->presentation)))
+       org->presentation))))

 (setlocale LC_ALL "")
 (exit-with-summary (run-all-defined-test-cases))


code:
From 501ad55982a8f92a7a95c76c75944d644870181d Mon Sep 17 00:00:00 2001
From: Ludovic Courtès <ludo@gnu.org>
Date: Thu, 12 Mar 2020 15:16:04 +0100
Subject: [PATCH] load: Make Guile run-time relocatable using /proc/self/exe.

Import from

    http://git.savannah.gnu.org/cgit/guix.git/commit/?id=920f2c42ce3345dc1355a41377ebf01a33fdae51
---
 libguile/load.c | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/libguile/load.c b/libguile/load.c
index c2ee5093a..128cdf95a 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -26,6 +26,7 @@

 #include <string.h>
 #include <stdio.h>
+#include <libgen.h>

 #include "libguile/_scm.h"
 #include "libguile/alist.h"
@@ -325,6 +326,32 @@ scm_init_load_path ()
   SCM cpath = SCM_EOL;

 #ifdef SCM_LIBRARY_DIR
+  char *program, *bin_dir, *prefix, *module_dir, *ccache_dir;
+
+  /* Determine the source and compiled module directories at run-time,
+     relative to the executable's location.
+
+     Note: Use /proc/self/exe instead of argv[0] because the latter is
+     not necessarily an absolute, nor a valid file name.  */
+
+  program = scm_gc_malloc_pointerless (256, "string");
+  readlink ("/proc/self/exe", program, 256);
+
+  bin_dir = dirname (strdupa (program));
+
+  prefix = scm_gc_malloc_pointerless (strlen (bin_dir) + 4, "string");
+  strcpy (prefix, bin_dir);
+  strcat (prefix, "/..");
+  prefix = canonicalize_file_name (prefix);
+
+  module_dir = scm_gc_malloc_pointerless (strlen (prefix) + 50, "string");
+  strcpy (module_dir, prefix);
+  strcat (module_dir, "/share/guile/" SCM_EFFECTIVE_VERSION);
+
+  ccache_dir = scm_gc_malloc_pointerless (strlen (prefix) + 50, "string");
+  strcpy (ccache_dir, prefix);
+  strcat (ccache_dir, "/lib/guile/" SCM_EFFECTIVE_VERSION "/ccache");
+
   env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_PATH"));
   if (env && strcmp (env, "") == 0)
     /* special-case interpret system-path=="" as meaning no system path instead
@@ -333,10 +360,7 @@ scm_init_load_path ()
   else if (env)
     path = scm_parse_path (scm_from_locale_string (env), path);
   else
-    path = scm_list_4 (scm_from_locale_string (SCM_LIBRARY_DIR),
-                       scm_from_locale_string (SCM_SITE_DIR),
-                       scm_from_locale_string (SCM_GLOBAL_SITE_DIR),
-                       scm_from_locale_string (SCM_PKGDATA_DIR));
+    path = scm_list_1 (scm_from_locale_string (module_dir));

   env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_COMPILED_PATH"));
   if (env && strcmp (env, "") == 0)
@@ -346,8 +370,7 @@ scm_init_load_path ()
     cpath = scm_parse_path (scm_from_locale_string (env), cpath);
   else
     {
-      cpath = scm_list_2 (scm_from_locale_string (SCM_CCACHE_DIR),
-                          scm_from_locale_string (SCM_SITE_CCACHE_DIR));
+      cpath = scm_list_1 (scm_from_locale_string (ccache_dir));
     }

 #endif /* SCM_LIBRARY_DIR */
--
2.24.0


code:
This patch fixes a bug in guile-rsvg's build system, whereby the CFLAGS
and LDFLAGS for Guile would not be captured.

--- guile-rsvg-2.18.1/configure.ac	2015-08-31 22:30:30.578909480 +0200
+++ guile-rsvg-2.18.1/configure.ac	2015-08-31 22:32:15.071516084 +0200
@@ -39,6 +39,10 @@ AC_SUBST(WARN_CFLAGS)

 GUILE_PKG([2.2 2.0 1.8])

+dnl The above macro fails to set the 'GUILE_CFLAGS' and 'GUILE_LIBS'
+dnl substitution variables, hence this line.
+PKG_CHECK_MODULES(GUILE, guile-$GUILE_EFFECTIVE_VERSION)
+
 PKG_CHECK_MODULES(GUILE_CAIRO, guile-cairo >= 1.4.0)
 AC_SUBST(GUILE_CAIRO_LIBS)
 AC_SUBST(GUILE_CAIRO_CFLAGS)


code:
Source: https://gitlab.gnome.org/GNOME/gvfs/-/commit/13551f3f40d41f1357126ac5a26d0fa012cd8123

Note: This change should be incorporated into stable version 1.46.x of gvfs.

From 13551f3f40d41f1357126ac5a26d0fa012cd8123 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Tue, 16 Jun 2020 13:28:35 +0200
Subject: [PATCH] afc: Add support for libplist-2.2

Which changed name from libplist to libplist-2.0 to embed its API
version number in the library name.
---
 meson.build | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 1750f65ca..187bfd55f 100644
--- a/meson.build
+++ b/meson.build
@@ -357,7 +357,10 @@ config_h.set('HAVE_LOGIND', enable_logind)
 enable_afc = get_option('afc')
 if enable_afc
   libimobiledevice_dep = dependency('libimobiledevice-1.0', version: '>= 1.2')
-  libplist_dep = dependency('libplist', version: '>= 0.15')
+  libplist_dep = dependency('libplist-2.0', required: false)
+  if not libplist_dep.found()
+    libplist_dep = dependency('libplist', version: '>= 0.15')
+  endif
 endif

 # *** Check if we should build with GOA volume monitor ***
--
GitLab


code:
--- /CMakeLists.txt	2020-01-20 21:47:35.460119141 +0100
+++ /CMakeLists.txt	2020-01-20 21:47:47.690112400 +0100
@@ -195,12 +195,12 @@
 #endif()

 # GME
-#find_path( GME_INCLUDE_DIR gme/gme.h )
-#find_library( GME_LIBRARIES gme )
-#mark_as_advanced( GME_INCLUDE_DIR GME_LIBRARIES )
-#FIND_PACKAGE_HANDLE_STANDARD_ARGS( GME
-#	REQUIRED_VARS GME_LIBRARIES GME_INCLUDE_DIR
-#)
+find_path( GME_INCLUDE_DIR gme/gme.h )
+find_library( GME_LIBRARIES gme )
+mark_as_advanced( GME_INCLUDE_DIR GME_LIBRARIES )
+FIND_PACKAGE_HANDLE_STANDARD_ARGS( GME
+	REQUIRED_VARS GME_LIBRARIES GME_INCLUDE_DIR
+)

 if( MSVC )
 	# Eliminate unreferenced functions and data


code:
Lookup gzdoom pk3 files in the installed directory in
addition to the path that is stored in ~/.config/gzdoom/.

Simply replacing the hardcoded /usr/share would leave the
configfile pointing to outdated guix builds, which could get
garbage collected and break the gzdoom installation.
This ensures that the files installed with the corresponding
build will be used.

--- /src/d_main.cpp	2018-01-16 22:13:09.700602781 +0200
+++ /src/d_main.cpp	2018-01-16 22:22:36.560617961 +0200
@@ -1716,6 +1716,11 @@
 		return wad;
 	}

+    mysnprintf (wad, countof(wad), "%s/%s", GUIX_OUT_PK3, file);
+    if (DirEntryExists (wad)) {
+        return wad;
+    }
+
 	if (GameConfig != NULL && GameConfig->SetSection ("FileSearch.Directories"))
 	{
 		const char *key;


code:
Changes necessary for shared library linking to succeed.

diff --git a/src/Makefile.in b/src/Makefile.in
index 9534473..12411bf 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -73,7 +73,7 @@ LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) \
 	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
 	$(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+LINK = HDF4_USE_SHLIB=yes $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(AM_LDFLAGS) $(LDFLAGS) -o $@
 SOURCES = $(libhdfeos_la_SOURCES)
 DIST_SOURCES = $(libhdfeos_la_SOURCES)
@@ -125,8 +125,6 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@

-# Set LDFLAGS to alow the HDF-EOS library to use extern variables from HDF4
-LDFLAGS = -Wl,-single_module
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@


code:
Fix multi-line string formatting in fortran test programs (reported upstream).

diff --git a/samples/appendfield.f b/samples/appendfield.f
index 42c4b6b..58257f7 100644
--- a/samples/appendfield.f
+++ b/samples/appendfield.f
@@ -22,8 +22,8 @@ c
          inarray(i) = i
       enddo

-      swfid = swopen("SwathFile_created_with_hadeos_sample_file_writer_o
-     1f_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+      swfid = swopen("SwathFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
       swid = swattach(swfid, "Swath1")

diff --git a/samples/definefields.f b/samples/definefields.f
index 89859e4..f3b3497 100644
--- a/samples/definefields.f
+++ b/samples/definefields.f
@@ -24,8 +24,8 @@ c	DFACC_RDWR accesscode in the open statement.  The SWopen
 c	routine returns the swath fileid, swfid, which is used to
 c	identify the file in subsequent routines.

-	swfid = swopen("SwathFile_created_with_hadeos_sample_file_writer
-     1_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	swfid = swopen("SwathFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 c
diff --git a/samples/definegdflds.f b/samples/definegdflds.f
index 177422e..1b7fcf6 100644
--- a/samples/definegdflds.f
+++ b/samples/definegdflds.f
@@ -21,8 +21,8 @@
 	fillval1=-7.0
 	fillval2=-9999.0

-	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_writer_
-     1of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 	gdid1 = gdattach(gdfid, "UTMGrid")
diff --git a/samples/definelevels.f b/samples/definelevels.f
index 2496d5f..64b2842 100644
--- a/samples/definelevels.f
+++ b/samples/definelevels.f
@@ -32,8 +32,8 @@ c	DFACC_RDWR access code in the open statement.  The ptopen
 c	routine returns the point fileid, ptfid, which is used to
 c	identify the file in subsequent routines.

-	ptfid = ptopen("PointFile_created_with_hadeos_sample_file_writer
-     1_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	ptfid = ptopen("PointFile_created_with_hadeos_sample_file_write"//
+     1  "r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 c
diff --git a/samples/inquiregrid.f b/samples/inquiregrid.f
index 8110461..8ce71e4 100644
--- a/samples/inquiregrid.f
+++ b/samples/inquiregrid.f
@@ -18,8 +18,8 @@

-	gdfid = gdopen('GridFile_created_with_hadeos_sample_file_writer_
-     1of_HDFEOS2_version_219_or_higher_release.hdf', DFACC_READ)
+	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)

 	if (gdfid .ne. -1) then
diff --git a/samples/inquireswath.f b/samples/inquireswath.f
index 899ee59..78c292b 100644
--- a/samples/inquireswath.f
+++ b/samples/inquireswath.f
@@ -24,8 +24,8 @@ c
 c	Open the Swath File for read only access
 c

-	swfid = swopen("SwathFile_created_with_hadeos_sample_file_writer
-     1_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)
+	swfid = swopen("SwathFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)

 	if (swfid .NE. -1) then
diff --git a/samples/readdimscalegrid.f b/samples/readdimscalegrid.f
index fed5540..a0bb48a 100644
--- a/samples/readdimscalegrid.f
+++ b/samples/readdimscalegrid.f
@@ -34,8 +34,8 @@
 !     * id, gdfid, which is used to identify the file in subsequent routines.
 !     */

-	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_writer_
-     1of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 !    /*
 !     * If the grid file cannot be found, gdopen will return -1 for the file
diff --git a/samples/readdimscaleswath.f b/samples/readdimscaleswath.f
index 97b6264..1b61624 100644
--- a/samples/readdimscaleswath.f
+++ b/samples/readdimscaleswath.f
@@ -33,8 +33,8 @@
 !     * id, swfid, which is used to identify the file in subsequent routines.
 !     */

-	swfid = swopen("SwathFile_created_with_hadeos_sample_file_writer
-     1_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	swfid = swopen("SwathFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 !    /*
 !     * If the swath file cannot be found, swopen will return -1 for the file
diff --git a/samples/readfields.f b/samples/readfields.f
index 873b30a..29d42f0 100644
--- a/samples/readfields.f
+++ b/samples/readfields.f
@@ -21,8 +21,8 @@ c
 c     Open the HDF swath file, "SwathFile.hdf"
 c

-	swfid = swopen("SwathFile_created_with_hadeos_sample_file_writer
-     1_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)
+	swfid = swopen("SwathFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)

 	if (swfid .NE. -1) then
diff --git a/samples/readgdflds.f b/samples/readgdflds.f
index e5fe85f..ff2bd86 100644
--- a/samples/readgdflds.f
+++ b/samples/readgdflds.f
@@ -9,8 +9,8 @@
 	integer DFNT_FLOAT32
 	parameter (DFNT_FLOAT32=5)

-	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_writer_
-     1of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 	if (gdfid .ne. -1) then

diff --git a/samples/readlevels.f b/samples/readlevels.f
index a7fd033..f349398 100644
--- a/samples/readlevels.f
+++ b/samples/readlevels.f
@@ -36,8 +36,8 @@ c
 c     Open the HDF swath file, "PointFile.hdf".
 c

-	ptfid = ptopen("PointFile_created_with_hadeos_sample_file_writer
-     1_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)
+	ptfid = ptopen("PointFile_created_with_hadeos_sample_file_write"//
+     +  "r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)

 c
 c    Read Simple Point
@@ -47,6 +47,8 @@ c
 	status = ptlevinfo(ptid, 0, fldlist, fldtype, fldorder)
 	n = ptnrecs(ptid, 0)

+	write(*,*) n
+
 	do 5 i=1,n
 	   recs(i) = i - 1
  5	continue
diff --git a/samples/setupgrid.f b/samples/setupgrid.f
index be5408c..cf4bd04 100644
--- a/samples/setupgrid.f
+++ b/samples/setupgrid.f
@@ -34,8 +34,8 @@ c      code in the open statement.  The GDopen routine returns the grid
 c      file id, gdfid, which is used to identify the file in subsequent
 c      routines in the library.
 c
-      gdfid = gdopen('GridFile_created_with_hadeos_sample_file_writer_of
-     1_HDFEOS2_version_219_or_higher_release.hdf',DFACC_CREATE)
+      gdfid = gdopen('GridFile_created_with_hadeos_sample_file_writer_"//
+     1"of_HDFEOS2_version_219_or_higher_release.hdf',DFACC_CREATE)

 c
 c     Create UTM Grid
diff --git a/samples/setupswath.f b/samples/setupswath.f
index d0289d6..fbaa0bb 100644
--- a/samples/setupswath.f
+++ b/samples/setupswath.f
@@ -22,8 +22,8 @@ c      code in the open statement.  The SWopen routine returns the swath
 c      file id, swfid, which is used to identify the file in subsequent
 c      routines in the library.
 c
-      swfid = swopen('SwathFile_created_with_hadeos_sample_file_writer_o
-     1f_HDFEOS2_version_219_or_higher_release.hdf',DFACC_CREATE)
+      swfid = swopen("SwathFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf",DFACC_CREATE)

 c
 c     The first of these, SWcreate, creates the swath, "Swath1", within the
diff --git a/samples/subsetgrid.f b/samples/subsetgrid.f
index c57e541..087e5b1 100644
--- a/samples/subsetgrid.f
+++ b/samples/subsetgrid.f
@@ -22,8 +22,8 @@ c
 c     Open the HDF grid file, "GridFile.hdf"
 c

-	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_writer_
-     1of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)
+	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)

 	if (gdfid .NE. -1) then

diff --git a/samples/subsetpoint.f b/samples/subsetpoint.f
index 9e72c5f..2e76d7d 100644
--- a/samples/subsetpoint.f
+++ b/samples/subsetpoint.f
@@ -21,8 +21,8 @@ c
 c     Open the HDF point file, "PointFile.hdf"
 c

-	ptfid = ptopen("PointFile_created_with_hadeos_sample_file_writer
-     1_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)
+	ptfid = ptopen("PointFile_created_with_hadeos_sample_file_write"//
+     1  "r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)

 	if (ptfid .NE. -1) then

diff --git a/samples/subsetswath.f b/samples/subsetswath.f
index dcee609..9af8a46 100644
--- a/samples/subsetswath.f
+++ b/samples/subsetswath.f
@@ -28,8 +28,8 @@ c
 c     Open the HDF swath file, "SwathFile.hdf"
 c

-	swfid = swopen("SwathFile_created_with_hadeos_sample_file_writer
-     1_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)
+	swfid = swopen("SwathFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_READ)

 	if (swfid .NE. -1) then

diff --git a/samples/writedimscalegrid.f b/samples/writedimscalegrid.f
index 09688d8..42013fe 100644
--- a/samples/writedimscalegrid.f
+++ b/samples/writedimscalegrid.f
@@ -29,8 +29,8 @@
 !     * id, gdfid, which is used to identify the file in subsequent routines.
 !     */

-	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_writer_
-     1of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 !    /*
 !     * If the grid file cannot be found, gdopen will return -1 for the file
diff --git a/samples/writedimscaleswath.f b/samples/writedimscaleswath.f
index 1151671..1a911a6 100644
--- a/samples/writedimscaleswath.f
+++ b/samples/writedimscaleswath.f
@@ -31,8 +31,8 @@
 !     * id, swfid, which is used to identify the file in subsequent routines.
 !     */

-	swfid = swopen("SwathFile_created_with_hadeos_sample_file_write
-     1r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	swfid = swopen("SwathFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 !    /*
 !     * If the swath file cannot be found, swopen will return -1 for the file
diff --git a/samples/writefields.f b/samples/writefields.f
index a743661..862b96c 100644
--- a/samples/writefields.f
+++ b/samples/writefields.f
@@ -31,8 +31,8 @@ c
 c     Open the HDF swath file, "SwathFile.hdf"
 c

-	swfid = swopen("SwathFile_created_with_hadeos_sample_file_writer
-     1_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	swfid = swopen("SwathFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 	if (swfid .NE. -1) then
diff --git a/samples/writegdflds.f b/samples/writegdflds.f
index d1540b3..81aef75 100644
--- a/samples/writegdflds.f
+++ b/samples/writegdflds.f
@@ -23,8 +23,8 @@
 	enddo

-	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_writer_
-     1of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	gdfid = gdopen("GridFile_created_with_hadeos_sample_file_write"//
+     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 	if (gdfid .ne. -1) then

diff --git a/samples/writelevels.f b/samples/writelevels.f
index 88e7780..cb40c9e 100644
--- a/samples/writelevels.f
+++ b/samples/writelevels.f
@@ -32,8 +32,8 @@ c
 c     Open the HDF point file, "PointFile.hdf".
 c

-	ptfid = ptopen("PointFile_created_with_hadeos_sample_file_writer
-     1_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
+	ptfid = ptopen("PointFile_created_with_hadeos_sample_file_write"//
+     +  "r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)

 c
--
2.10.0


code:
Don't build the GCTP bundled with the source and link with the
system's -lgctp instead.  We also remove references to the
"testdrivers" directory, which is not distributed together with the
source, causing autoreconf to fail.

diff --git a/Makefile.in b/Makefile.in
index d468af2..90428a7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -206,7 +206,7 @@ LIBGCTP = $(top_builddir)/gctp/src/libGctp.la
 @TESTDRIVERS_CONDITIONAL_TRUE@TESTDRIVERS = testdrivers
 @INSTALL_INCLUDE_CONDITIONAL_FALSE@INCLUDE =
 @INSTALL_INCLUDE_CONDITIONAL_TRUE@INCLUDE = include
-SUBDIRS = gctp src $(INCLUDE) samples $(TESTDRIVERS)
+SUBDIRS = src $(INCLUDE) samples $(TESTDRIVERS)
 all: all-recursive

 .SUFFIXES:
diff --git a/include/Makefile.in b/include/Makefile.in
index 9938b23..afb7f40 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -190,7 +190,7 @@ LIBGCTP = $(top_builddir)/gctp/src/libGctp.la
 # Boilerplate include

 # Headers to install
-include_HEADERS = HE2_config.h HdfEosDef.h HDFEOSVersion.h cfortHdf.h ease.h
+include_HEADERS = HdfEosDef.h HDFEOSVersion.h cfortHdf.h ease.h
 all: HE2_config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-am

diff --git a/samples/Makefile.in b/samples/Makefile.in
index 9da6e28..6a6186c 100644
--- a/samples/Makefile.in
+++ b/samples/Makefile.in
@@ -108,7 +108,6 @@ AppendField_SOURCES = AppendField.c
 AppendField_OBJECTS = AppendField.$(OBJEXT)
 AppendField_LDADD = $(LDADD)
 am__DEPENDENCIES_1 = $(top_builddir)/src/libhdfeos.la
-am__DEPENDENCIES_2 = $(top_builddir)/gctp/src/libGctp.la
 AppendField_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
 DefineFields_SOURCES = DefineFields.c
 DefineFields_OBJECTS = DefineFields.$(OBJEXT)
@@ -481,7 +480,7 @@ sharedstatedir = @sharedstatedir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 LIBHDFEOS2 = $(top_builddir)/src/libhdfeos.la
-LIBGCTP = $(top_builddir)/gctp/src/libGctp.la
+LIBGCTP =

 # Boilerplate definitions file

--
2.10.0


code:
Make shared library linking work.
---
 src/Makefile.in | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/Makefile.in b/src/Makefile.in
index 86880e5..24efffe 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -72,7 +72,7 @@ LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) \
 	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
 	$(AM_CFLAGS) $(CFLAGS) -DH5_USE_16_API
 CCLD = $(CC)
-LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+LINK = HDF5_USE_SHLIB=yes $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(AM_LDFLAGS) $(LDFLAGS) -o $@
 SOURCES = $(libhe5_hdfeos_la_SOURCES)
 DIST_SOURCES = $(libhe5_hdfeos_la_SOURCES)
@@ -124,9 +124,6 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@

-# Set LDFLAGS to allow the HDF-EOS library to use extern variables from
-# HDF5
-LDFLAGS = -Wl,-single_module
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
--
2.10.0


code:
Ill-placed #endif causes missing symbol errors when compiling without
szip.  Reported to upstream maintainer.
---
 src/EHapi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/EHapi.c b/src/EHapi.c
index 46a9b5c..208f447 100755
--- a/src/EHapi.c
+++ b/src/EHapi.c
@@ -11379,6 +11379,7 @@ int HE5_szip_can_encode(void )
   return(-1);
 }

+#endif /* H5_HAVE_FILTER_SZIP */

 /*----------------------------------------------------------------------------|
@@ -11509,8 +11510,6 @@ HE5_EHHEisHE5(char *filename)
     }
 }

-#endif /* H5_HAVE_FILTER_SZIP */
-

 #ifndef __cplusplus

--
2.10.0