File 0001-fix-always-zero-terminate-idna-output.patch of Package libuv.36527

From 0f2d7e784a256b54b2385043438848047bc2a629 Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <info@bnoordhuis.nl>
Date: Thu, 18 Jan 2024 14:51:40 +0100
Subject: [PATCH 1/3] fix: always zero-terminate idna output

Fixes: https://github.com/libuv/libuv/security/advisories/GHSA-f74f-cvh7-c6q6
---
 src/idna.c       | 5 +++--
 test/test-idna.c | 4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

Index: libuv-v1.44.2/src/idna.c
===================================================================
--- libuv-v1.44.2.orig/src/idna.c
+++ libuv-v1.44.2/src/idna.c
@@ -308,8 +308,9 @@ long uv__idna_toascii(const char* s, con
       return rc;
   }
 
-  if (d < de)
-    *d++ = '\0';
+  if (d >= de)
+    return UV_EINVAL;
 
+  *d++ = '\0';
   return d - ds;  /* Number of bytes written. */
 }
Index: libuv-v1.44.2/test/test-idna.c
===================================================================
--- libuv-v1.44.2.orig/test/test-idna.c
+++ libuv-v1.44.2/test/test-idna.c
@@ -99,6 +99,7 @@ TEST_IMPL(utf8_decode1) {
 TEST_IMPL(utf8_decode1_overrun) {
   const char* p;
   char b[1];
+  char c[1];
 
   /* Single byte. */
   p = b;
@@ -112,6 +113,9 @@ TEST_IMPL(utf8_decode1_overrun) {
   ASSERT_EQ((unsigned) -1, uv__utf8_decode1(&p, b + 1));
   ASSERT_EQ(p, b + 1);
 
+  b[0] = 0x7F;
+  ASSERT_EQ(UV_EINVAL, uv__idna_toascii(b, b + 1, c, c + 1));
+
   return 0;
 }
 
openSUSE Build Service is sponsored by