Commit eecd2dee1a6 for nodejs

commit eecd2dee1a6a4175131f523690b2d4701e20341e
Author: Azhar <stfuazzo@gmail.com>
Date:   Mon Nov 30 17:26:16 2026 +0530

    util: guard callbackify against deleted length and name properties

    Fixes: https://github.com/nodejs/node/issues/67745

    Signed-off-by: bunnysayzz <stfuazzo@gmail.com>
    PR-URL: https://github.com/nodejs/node/pull/67754
    Fixes: https://github.com/nodejs/node/issues/67745
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
    Reviewed-By: Jordan Harband <ljharb@gmail.com>
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>

diff --git a/lib/util.js b/lib/util.js
index 02e205c8e16..b3306a539d9 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -419,10 +419,10 @@ function callbackify(original) {
   const descriptors = ObjectGetOwnPropertyDescriptors(original);
   // It is possible to manipulate a functions `length` or `name` property. This
   // guards against the manipulation.
-  if (typeof descriptors.length.value === 'number') {
+  if (typeof descriptors.length?.value === 'number') {
     descriptors.length.value++;
   }
-  if (typeof descriptors.name.value === 'string') {
+  if (typeof descriptors.name?.value === 'string') {
     descriptors.name.value += 'Callbackified';
   }
   const propertiesValues = ObjectValues(descriptors);
diff --git a/test/parallel/test-util-callbackify.js b/test/parallel/test-util-callbackify.js
index 3d366a6ccf6..38febc768b5 100644
--- a/test/parallel/test-util-callbackify.js
+++ b/test/parallel/test-util-callbackify.js
@@ -299,3 +299,47 @@ const values = [
     assert.match(stack[1], /at process\.processTicksAndRejections/);
   }));
 }
+
+{
+  // Test that deleting the `length` or `name` property of the original
+  // function does not throw (https://github.com/nodejs/node/issues/67745).
+  async function asyncFn() {
+    return 42;
+  }
+  delete asyncFn.length;
+  delete asyncFn.name;
+  const cbAsyncFn = callbackify(asyncFn);
+  cbAsyncFn(common.mustSucceed((ret) => {
+    assert.strictEqual(ret, 42);
+  }));
+
+  function promiseFn() {
+    return Promise.resolve(42);
+  }
+  delete promiseFn.length;
+  const cbPromiseFn = callbackify(promiseFn);
+  cbPromiseFn(common.mustSucceed((ret) => {
+    assert.strictEqual(ret, 42);
+  }));
+}
+
+{
+  // Test that a `length` or `name` descriptor with a null value does not
+  // throw (https://github.com/nodejs/node/pull/67754#pullrequestreview-6063276391).
+  async function asyncFn() {
+    return 42;
+  }
+  const proxyFn = new Proxy(asyncFn, {
+    getOwnPropertyDescriptor(target, property) {
+      const descriptor = Reflect.getOwnPropertyDescriptor(target, property);
+      if (property === 'length' || property === 'name') {
+        return { ...descriptor, value: null };
+      }
+      return descriptor;
+    },
+  });
+  const cbProxyFn = callbackify(proxyFn);
+  cbProxyFn(common.mustSucceed((ret) => {
+    assert.strictEqual(ret, 42);
+  }));
+}