u_int8_t *pos;
u_int8_t seg[3], rchassis;
struct in_addr address;
+ char ip_addr[INET_ADDRSTRLEN];
log_debug("sonmp", "decode SONMP PDU from %s", hardware->h_ifname);
chassis->c_id[0] = 1;
PEEK_BYTES(&address, sizeof(struct in_addr));
memcpy(chassis->c_id + 1, &address, sizeof(struct in_addr));
- if (asprintf(&chassis->c_name, "%s", inet_ntoa(address)) == -1) {
+ if (inet_ntop(AF_INET, &address, ip_addr, sizeof(ip_addr)) == NULL) {
+ log_warnx("sonmp", "unable to convert chassis address for %s",
+ hardware->h_ifname);
+ goto malformed;
+ }
+ if (asprintf(&chassis->c_name, "%s", ip_addr) == -1) {
log_warnx("sonmp", "unable to write chassis name for %s",
hardware->h_ifname);
goto malformed;