Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipv4 column append problem #88

Closed
BozaB opened this issue May 5, 2021 · 2 comments
Closed

ipv4 column append problem #88

BozaB opened this issue May 5, 2021 · 2 comments

Comments

@BozaB
Copy link

BozaB commented May 5, 2021

Dear clickhouse-cpp team,

The following function in clickhouse-cpp/clickhouse/columns/ip4.cpp is always thrown an exception, when ipv4 address is 255.255.255.255:

void ColumnIPv4::Append(const std::string& str) {
    in_addr_t addr = inet_addr(str.c_str());
    if (addr == INADDR_NONE) {
        throw std::runtime_error("invalid IPv4 format, ip: " + str);
    }
    data_->Append(htonl(addr));
}

Because inet_addr function is obsolete, and this is a known issue. https://www.gnu.org/software/libc/manual/html_node/Host-Address-Functions.html

The possible solution is the following:

void ColumnIPv4::Append(const std::string& str) {
    struct in_addr addr;
    if (inet_aton(str.c_str(),&addr) == 0) {
        throw std::runtime_error("invalid IPv4 format, ip: " + str);
    }
    data_->Append(htonl(addr.s_addr));
}

Please solve this problem.

Thank you and best regards,
BB

@filimonov
Copy link
Collaborator

Can you send a PR with that change? (this way you will be an author of that :) )

@Enmk
Copy link
Collaborator

Enmk commented Feb 3, 2022

Closed by #148

@Enmk Enmk closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants