dgram: tighten `address` validation in `socket.send` · nodejs/node@40c6e83 · GitHub
Skip to content

Commit 40c6e83

Browse files
VoltrexKeyvatargos
authored andcommitted
dgram: tighten address validation in socket.send
PR-URL: #39190 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 6bfe5a6 commit 40c6e83

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

doc/api/dgram.md

Lines changed: 5 additions & 1 deletion

lib/dgram.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ Socket.prototype.send = function(buffer,
636636
if (typeof address === 'function') {
637637
callback = address;
638638
address = undefined;
639-
} else if (address && typeof address !== 'string') {
640-
throw new ERR_INVALID_ARG_TYPE('address', ['string', 'falsy'], address);
639+
} else if (address != null) {
640+
validateString(address, 'address');
641641
}
642642

643643
healthCheck(this);

test/parallel/test-dgram-send-address-types.js

Lines changed: 16 additions & 4 deletions

0 commit comments

Comments
 (0)