<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From e422ca79ef1e56c78527b91cbb8c406149897949 Mon Sep 17 00:00:00 2001
From: Pete Batard &lt;pete@akeo.ie&gt;
Date: Tue, 19 May 2020 18:01:30 +0100
Subject: [PATCH 1/1] Fix gcc strncpy related warnings

gcc 10 on MinGW generates a handful of:
'strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=]
Either use memcpy() to avoid that remove the unneeded MIN in places where it is superfluous.

Also add guards for the GCC specific pragma in iso9660.c.
---
 lib/driver/cdio_private.h | 2 +-
 lib/iso9660/iso9660.c     | 2 ++
 lib/udf/udf_fs.c          | 4 ++--
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/driver/cdio_private.h b/lib/driver/cdio_private.h
index 0480c316..be39475f 100644
--- a/lib/driver/cdio_private.h
+++ b/lib/driver/cdio_private.h
@@ -55,7 +55,7 @@ static inline char *libcdio_strndup(const char *s, size_t n)
     if (!result)
         return 0;
     result[len] = '\0';
-    return (char *) strncpy (result, s, len);
+    return (char *) memcpy (result, s, len);
 }
 #endif /*HAVE_STRNDUP*/
 
diff --git a/lib/iso9660/iso9660.c b/lib/iso9660/iso9660.c
index bb514d95..ae4edda3 100644
--- a/lib/iso9660/iso9660.c
+++ b/lib/iso9660/iso9660.c
@@ -373,7 +373,9 @@ iso9660_set_ltime_with_timezone(const struct tm *p_tm,
 
   if (!p_tm) return;
 
+#if defined(__GNUC__)
 #pragma GCC diagnostic ignored "-Wformat-truncation"
+#endif
   snprintf(_pvd_date, 17,
            "%4.4d%2.2d%2.2d" "%2.2d%2.2d%2.2d" "%2.2d",
            p_tm-&gt;tm_year + 1900, p_tm-&gt;tm_mon + 1, p_tm-&gt;tm_mday,
diff --git a/lib/udf/udf_fs.c b/lib/udf/udf_fs.c
index c692bfb9..63240fef 100644
--- a/lib/udf/udf_fs.c
+++ b/lib/udf/udf_fs.c
@@ -475,7 +475,7 @@ udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid, unsigned int i_volid)
 
   volid_len = strlen(r)+1;     /* +1 for NUL terminator */
   if (psz_volid != NULL) {
-    strncpy(psz_volid, r, MIN(volid_len, i_volid));
+    strncpy(psz_volid, r, i_volid);
     psz_volid[i_volid-1] = 0;  /* strncpy does not always terminate the dest */
   }
   free(r);
@@ -541,7 +541,7 @@ udf_get_logical_volume_id(udf_t *p_udf, /*out*/ char *psz_logvolid, unsigned int
 
   logvolid_len = strlen(r)+1;  /* +1 for NUL terminator */
   if (psz_logvolid != NULL) {
-    strncpy(psz_logvolid, r, MIN(logvolid_len, i_logvolid));
+    strncpy(psz_logvolid, r, i_logvolid);
     psz_logvolid[i_logvolid-1] = 0;    /* strncpy does not always terminate the dest */
   }
   free(r);
-- 
2.50.0

</pre></body></html>