Menu

#1255 Mac code is using availability macros incorrectly

closed-fixed
None
5
2014-08-16
2013-07-11
Edward Rudd
No

Currently the libcurl code checks for MAC_10_? and IPHONE_?_? to determine what it is compiling against.. However that is incorrect usage, as those macros document what is installed on the development system, not what SDK is being compiled against. (yeah.. rather silly IMHO).

The cause is that some of the recent changes in darwin_ssl fail to compile when compiling on a 10.6 SDK. The CopyIdentityWithLabel includes some new code that has this define check

#if defined(__MAC_10_6) || defined(__IPHONE_2_0)
// check and use SecItemCopyMatching()
#endif

However, the SecItemCopyMatching code does not in fact compile on 10.6 SDK as an extra header needs to be included explicitly (<Security SecItem.h="">) AND it doesn't define kSecClassIdentity.

Now changing the definition to

#if defined(__MAC_10_7) || defined(__IPHONE_2_0)

however does not work as my /usr/include/Availability.h defines __IPHONE_2_0 (even in an Mac compilation) as I have that SDK installed on my system!.

The proper checks should be

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 20000

Read more on this usage in the Availability.h header itself.. These defines are automatically set by the compiler according to which SDK is being used to compile with. (and in the case of OS X compiling the iphone define is undefined and evaluates as 0 in the comparison so it works correctly.

Related

Bugs: #1255

Discussion

  • Daniel Stenberg

    Daniel Stenberg - 2013-07-14
    • status: open --> pending
    • assigned_to: Daniel Stenberg
     
  • Daniel Stenberg

    Daniel Stenberg - 2013-07-14

    This has since then been updated in the git repo. Can you please check the latest code there and see if you still spot any problem(s) ?

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-07-18
    • status: pending --> closed-works-for-me
     
  • Edward Rudd

    Edward Rudd - 2013-07-18

    It's almost there.. your lib/md5.c and src/tool_metalink.c still have checks against the MAC and IPHONE macros.. and I'll need to do some more testing on the "CopyIdentityWithLabel" method.. as it doesn't compile on a 10.6 SDK, so I'm going to compile on a 10.7/8 SDK and test that functionality on a 10.6 box to ensure the run-time checks work correctly. (yes SecItemCopyMatching was added in 10.6 BUT kSecClassIdentity was added on 10.7)

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-07-18

    Can I ask you to please take this subject to the curl-library mailing list and if possible provide a patch showing your suggested further edits?

    I'm not the Mac guy around here and discussing it on the list will make more people see it and possibly participate.

     
  • Daniel Stenberg

    Daniel Stenberg - 2013-07-25
    • status: closed-works-for-me --> pending-needsinfo
     
  • Daniel Stenberg

    Daniel Stenberg - 2013-07-31
    • status: pending-needsinfo --> pending
     
  • Daniel Stenberg

    Daniel Stenberg - 2013-07-31

    Nick Zitzmann wrote:

    For some reason I can't seem to access my Sourceforge account at the moment. But I did push two changes that ought to fix the remaining problems (incorrect use of macros, build breakage on Snow Leopard).

    http://curl.haxx.se/mail/lib-2013-07/0315.html

     
  • Edward Rudd

    Edward Rudd - 2013-07-31

    Ill revalidate against the latest git on all of my test systems.. Thanks!!

    On Jul 31, 2013, at 10:12 , Daniel Stenberg wrote:

    Nick Zitzmann wrote:

    For some reason I can't seem to access my Sourceforge account at the moment. But I did push two changes that ought to fix the remaining problems (incorrect use of macros, build breakage on Snow Leopard).

    http://curl.haxx.se/mail/lib-2013-07/0315.html

    [bugs:#1255] Mac code is using availability macros incorrectly

    Status: pending
    Created: Thu Jul 11, 2013 05:23 PM UTC by Edward Rudd
    Last Updated: Thu Jul 25, 2013 02:11 PM UTC
    Owner: Daniel Stenberg

    Currently the libcurl code checks for MAC_10_? and IPHONE_?_? to determine what it is compiling against.. However that is incorrect usage, as those macros document what is installed on the development system, not what SDK is being compiled against. (yeah.. rather silly IMHO).

    The cause is that some of the recent changes in darwin_ssl fail to compile when compiling on a 10.6 SDK. The CopyIdentityWithLabel includes some new code that has this define check

    if defined(MAC_10_6) || defined(IPHONE_2_0)

    // check and use SecItemCopyMatching()

    endif

    However, the SecItemCopyMatching code does not in fact compile on 10.6 SDK as an extra header needs to be included explicitly (SecItem.h>) AND it doesn't define kSecClassIdentity.

    Now changing the definition to

    if defined(MAC_10_7) || defined(IPHONE_2_0)

    however does not work as my /usr/include/Availability.h defines __IPHONE_2_0 (even in an Mac compilation) as I have that SDK installed on my system!.

    The proper checks should be

    if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 || IPHONE_OS_VERSION_MAX_ALLOWED >= 20000

    Read more on this usage in the Availability.h header itself.. These defines are automatically set by the compiler according to which SDK is being used to compile with. (and in the case of OS X compiling the iphone define is undefined and evaluates as 0 in the comparison so it works correctly.

    Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/curl/bugs/1255/

    To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

    Edward Rudd
    OutOfOrder.cc
    Skype: outoforder_cc
    317-674-3296

     

    Related

    Bugs: #1255

  • Daniel Stenberg

    Daniel Stenberg - 2013-08-02
    • status: pending --> closed-fixed