Skip to content

Commit b9e520a

Browse files
committed
Don't allow resolver to return 'localhost' for a non-loopback address.
1 parent 931ac99 commit b9e520a

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ v3.0.1 - YYYY-MM-DD
66

77
- Updated the internal implementation of `ipp_t` to avoid issues on some
88
embedded platforms (Issue #141)
9+
- Updated `httpAddrLookup` to return a numeric address when the resolver
10+
returns "localhost" for a non-loopback address.
911
- Fixed a bug when the `ippFindXxx` and `ippSetXxx` functions were mixed
1012
(Issue #138)
1113

cups/http-addr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// HTTP address routines for CUPS.
33
//
4-
// Copyright © 2021-2024 by OpenPrinting.
4+
// Copyright © 2021-2026 by OpenPrinting.
55
// Copyright © 2007-2021 by Apple Inc.
66
// Copyright © 1997-2006 by Easy Software Products, all rights reserved.
77
//
@@ -351,7 +351,7 @@ addr->un.sun_path, strerror(errno));
351351
// Bind the domain socket...
352352
if ((status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrGetLength(addr))) < 0)
353353
DEBUG_printf("1httpAddrListen: Unable to bind domain socket \"%s\": %s", addr->un.sun_path, strerror(errno));
354-
354+
355355
// Restore the umask and fix permissions...
356356
umask(mask);
357357
}
@@ -461,12 +461,12 @@ httpAddrLookup(
461461
// Fall back on httpAddrGetString if getnameinfo fails...
462462
int error = getnameinfo(&addr->addr, (socklen_t)httpAddrGetLength(addr), name, (socklen_t)namelen, NULL, 0, 0);
463463

464-
if (error)
464+
if (error || !strcasecmp(name, "localhost"))
465465
{
466466
if (error == EAI_FAIL)
467467
cg->need_res_init = 1;
468468

469-
return (httpAddrGetString(addr, name, namelen));
469+
httpAddrGetString(addr, name, namelen);
470470
}
471471

472472
DEBUG_printf("2httpAddrLookup: returning \"%s\"...", name);

0 commit comments

Comments
 (0)