Repository: trafficserver Updated Branches: refs/heads/master ec7479243 -> 0cd1ef3ed
TS-3803: CID 1313322 CID 1313322: HostDB memory issues (introduced in TS-3800) Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/0cd1ef3e Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/0cd1ef3e Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/0cd1ef3e Branch: refs/heads/master Commit: 0cd1ef3ed5e4e6e3a332bccdd07220be717f2226 Parents: ec74792 Author: Brian Geffon <[email protected]> Authored: Tue Jul 28 19:43:35 2015 -0700 Committer: Brian Geffon <[email protected]> Committed: Tue Jul 28 19:43:35 2015 -0700 ---------------------------------------------------------------------- iocore/hostdb/HostDB.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0cd1ef3e/iocore/hostdb/HostDB.cc ---------------------------------------------------------------------- diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc index 5a9c85a..0d36fd6 100644 --- a/iocore/hostdb/HostDB.cc +++ b/iocore/hostdb/HostDB.cc @@ -1365,10 +1365,18 @@ HostDBContinuation::lookup_done(IpAddr const &ip, char const *aname, bool around } } - const size_t s_size = strlen(aname) + 1; - void *host_dest = hostDB.alloc(&i->hostname_offset, s_size); - ink_strlcpy((char *)host_dest, aname, s_size); - *((char *)host_dest + s_size) = '\0'; + if (aname) { + const size_t s_size = strlen(aname) + 1; + void *host_dest = hostDB.alloc(&i->hostname_offset, s_size); + if (host_dest) { + ink_strlcpy((char *)host_dest, aname, s_size); + *((char *)host_dest + s_size) = '\0'; + } else { + Warning("Out of room in hostdb for hostname (data area full!)"); + hostDB.delete_block(i); + return NULL; + } + } if (from_cont) do_put_response(from, i, from_cont);
