浏览代码

libuv: backport IDNA input/output hardening fixes

Backport libuv commit `0f2d7e78` (fix: always zero-terminate idna
output, 2024-01-18, `v1.48.0~4`) and libuv commit `3530bcc3` (fix:
reject zero-length idna inputs, 2024-01-18, `v1.48.0~3`).

Fixes: #26112
Brad King 1 年之前
父节点
当前提交
890beb19e6
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      Utilities/cmlibuv/src/idna.c

+ 6 - 2
Utilities/cmlibuv/src/idna.c

@@ -274,6 +274,9 @@ long uv__idna_toascii(const char* s, const char* se, char* d, char* de) {
   char* ds;
   int rc;
 
+  if (s == se)
+    return UV_EINVAL;
+
   ds = d;
 
   si = s;
@@ -308,8 +311,9 @@ long uv__idna_toascii(const char* s, const char* se, char* d, char* de) {
       return rc;
   }
 
-  if (d < de)
-    *d++ = '\0';
+  if (d >= de)
+    return UV_EINVAL;
 
+  *d++ = '\0';
   return d - ds;  /* Number of bytes written. */
 }