}
// TODO: handle wildcard port numbers in the id
- if (memcmp(src->v, s->idsrc->v, s->idsrc->l) == 0) {
+ if ((src->l == s->idsrc->l) && memcmp(src->v, s->idsrc->v, s->idsrc->l) == 0) {
if (use_nat_addr) {
if (memcmp(lcconf->ext_nat_id->v, s->iddst->v, s->iddst->l) == 0) {
plogdump(ASL_LEVEL_DEBUG, lcconf->ext_nat_id->v, lcconf->ext_nat_id->l, "matched external nat address.\n");
return s;
}
- } else if (memcmp(dst->v, s->iddst->v, s->iddst->l) == 0)
+ } else if ((dst->l == s->iddst->l) && memcmp(dst->v, s->iddst->v, s->iddst->l) == 0) {
return s;
+ }
}
}
const char *
sainfo2str(const struct sainfo *si)
{
- char *idsrc_str;
- char *iddst_str;
- char *idi_str;
+ char *idsrc_str;
+ char *iddst_str;
+ char *idi_str;
static char buf[256];
if (si->idsrc == NULL)
snprintf(buf, sizeof(buf), "anonymous");
else {
- idsrc_str = ipsecdoi_id2str(si->idsrc);
- if (idsrc_str) {
- snprintf(buf, sizeof(buf), "%s", idsrc_str);
- racoon_free(idsrc_str);
- }
- iddst_str = ipsecdoi_id2str(si->iddst);
- if (iddst_str) {
- snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
- " %s", iddst_str);
- racoon_free(iddst_str);
- }
+ idsrc_str = ipsecdoi_id2str(si->idsrc);
+ if (idsrc_str) {
+ snprintf(buf, sizeof(buf), "%s", idsrc_str);
+ racoon_free(idsrc_str);
+ }
+ if (si->iddst == NULL) {
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " anonymous");
+ } else {
+ iddst_str = ipsecdoi_id2str(si->iddst);
+ if (iddst_str) {
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+ " %s", iddst_str);
+ racoon_free(iddst_str);
+ }
+ }
}
if (si->id_i != NULL) {
- idi_str = ipsecdoi_id2str(si->id_i);
- if (idi_str) {
- snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
- " from %s", idi_str);
- racoon_free(idi_str);
- }
- }
+ idi_str = ipsecdoi_id2str(si->id_i);
+ if (idi_str) {
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+ " from %s", idi_str);
+ racoon_free(idi_str);
+ }
+ }
return buf;
}