Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#38 libdkim should avoid using sm_strlcat & sm_strlcpy

v2.7.2
closed-accepted
5
2009-02-18
2008-12-03
Fredrik Pettai
No

To build third-party applications with dkim support (from libdkim), you need to use -lsm (sendmails libsm) for sm_strlcat and sm_strlcpy that are used in libdkim.
Then possible, (lib)dkim should utilize the OS native strlcat and strlcpy instead.

Discussion

  • The GNU libc, last I checked, didn't include the strlcat() and strlcpy() functions. It became simpler to include libsm in the distribution and used the clone functions present there.

    It may be possible simply to do this at the top of each libdkim C source file:

    #ifdef WITHOUT_LIBSM
    # define sm_strlcat strlcat
    # define sm_strlcpy strlcpy
    #else /* ... */
    # libsm-stuff-here
    #endif /* ... */

    You'd just have to make sure that the WITHOUT_LIBSM case also ensures the "bool" typedef and "__P" macro definitions are included somehow, and do so in a portable manner. And there may be other issues I haven't thought of yet.

    I don't have the cycles to cover this immediately, but perhaps someone can take a crack at it and contribute a patch if the need is urgent.

     
    • assigned_to: nobody --> sm-msk
     
    • milestone: --> 896428
     
    • milestone: 896428 --> v2.7.2
    • labels: 740972 -->
     
  • Try the attached patch, and make the corresponding change to your site.config.m4.
    File Added: PATCH

     
  • Proposed patch #1

     
    Attachments
    • labels: --> Feature Request
     
  • Fredrik Pettai
    Fredrik Pettai
    2009-02-06

    Thx,
    The patch applies well and I compiles under NetBSD 5.0_RC1.
    Now it just has to run some time to verify that is works as expected...

     
  • Fredrik Pettai
    Fredrik Pettai
    2009-02-06

    Thx,
    The patch applies well on dkim-milter-2.8.1 and I compiles under NetBSD 5.0_RC1.
    Now it just has to run some time to verify that is works as expected...

     
  • Fredrik Pettai
    Fredrik Pettai
    2009-02-06

    Addon to patch #2

     
    Attachments
  • Fredrik Pettai
    Fredrik Pettai
    2009-02-06

    I patched some more files (see PATCH2) and after that all references to sm_strlcat() & sm_strlcpy() gone.
    But now I get some new warnings as well.

    File Added: PATCH2

     
  • I'm not clear on why those changes are needed. libdkim doesn't contain the files you included in your patch (one was in libar, the others were test binaries), so it shouldn't include any more references to the sm_strl*() functions.

    I just tried the patch on Linux, FreeBSD and Solaris 9, and none of them produced a library with any references to the sm_strl*() functions.

     
  • The proposed patch, plus part of the submitted patch (the libar/ar.c part), will be included as part of 2.8.2 which will come out later this month.

     
    • status: open --> closed-accepted
     
  • Patch to make this optional at compile time (-DWITHOUT_LIBSM) available in v2.8.2, now released.