>      int count = 0;
>  
> +    /* Allow trailing wildcard */
> +    int len = strlen(del_cn);
> +    len += (len > 1 && del_cn[len-1] == '*') ? -1 : 1;

This is very compact and not very readable

A comment that says why you are adding +1 would be good.

I first thought it was incorrect and went through godbolt to figure out
the '*' string is longer so its prefix is short and normal string needs
the \0 instead: https://godbolt.org/z/vqsPeW


> +
>      hash_iterator_init(m->iter, &hi);
>      while ((he = hash_iterator_next(&hi)))
>      {
> @@ -3779,7 +3783,7 @@ management_callback_kill_by_cn(void *arg, const char 
> *del_cn)
>          if (!mi->halt)
>          {
>              const char *cn = tls_common_name(mi->context.c2.tls_multi, 
> false);
> -            if (cn && !strcmp(cn, del_cn))
> +            if (cn && !strncmp(cn, del_cn, len))
>              {
>                  multi_signal_instance(m, mi, SIGTERM);
>                  ++count;
> 

Feature-Ack. But I would like the string len magic be documented/written
in a better understandable way.

Arne

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to