#3899: mutt_ssl's interactive_check_cert() has several issues
-----------------------+----------------------
  Reporter:  kevin8t8  |      Owner:  mutt-dev
      Type:  defect    |     Status:  closed
  Priority:  major     |  Milestone:
 Component:  crypto    |    Version:
Resolution:  fixed     |   Keywords:
-----------------------+----------------------

Comment (by kevin8t8):

 Damien chimed in on #mutt to point out Linux has something which does
 this: ARRAY_SIZE http://lxr.free-
 electrons.com/source/include/linux/kernel.h#L53.

 You can trace it through, but it ends up using a gcc extension
 !__builtin_types_compatible_p.

 To abort compilation, it uses BUILD_BUG_ON_ZERO.  But I can't figure this
 macro out.  It looks like this macro fails *unless* you pass it zero.  So
 perhaps I'm looking at the wrong instantiation of this or something.
 Hopefully Damien or someone can unconfuse me.

 In any case, if we use Vincent's declaration instead of the gcc extension,
 this gives us a possibility:

 {{{
 #define BUILD_BUG_UNLESS_ZERO(e) (sizeof(struct { int:-!!(e); }))
 #define __must_be_array(a)   BUILD_BUG_UNLESS_ZERO((void *) &(a) != (void
 *) &(a)[0])
 #define mutt_array_size(x)   (sizeof (x) / sizeof ((x)[0]) +
 __must_be_array(x))
 }}}

--
Ticket URL: <https://dev.mutt.org/trac/ticket/3899#comment:22>
Mutt <http://www.mutt.org/>
The Mutt mail user agent

Reply via email to