Page MenuHome GnuPG

curses: Avoid including system <memory.h> header
AcceptedPublic

Authored by chrstphrchvz on Mar 20 2023, 4:57 AM.

Details

Reviewers
werner
Summary

On macOS and other BSD OSes, there exists a memory.h system header (which just includes <string.h>). pinentry/pinentry-curses.c should include pinentry’s own memory.h using #include "memory.h" (as already done elsewhere in pinentry) rather than #include <memory.h> to prevent a system memory.h header from taking precedence and leading to implicit declaration of secmem_free() (which Xcode clang 12 and LLVM clang 16 consider an error by default rather than a warning).

This issue was observed by MacPorts (see https://trac.macports.org/ticket/61421) for the defunct pinentry-mac fork, which is where I originally tried submitting this change to (see https://github.com/GPGTools/pinentry-mac/pull/8).

Test Plan

I am not aware of what I should put here. This change is already successfully in use downstream on macOS, so I am just submitting it here for consideration by upstream.

Diff Detail

Repository
rP Pinentry
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

chrstphrchvz created this revision.
werner added a subscriber: werner.

This header was introduced close to 20 years ago. I agree that it does not make any sense - it might be a left-over from an old Hurd version. We can entirely remove it because string.h is already included and we also don't use memory.h anywhere in gnupg proper.

This revision is now accepted and ready to land.Mar 20 2023, 8:10 AM

Turned out to be a bit come complicated. I hope that I did not break any of the other pinentries:
rP8ab1682e80a2b4185ee9ef66cbb44340245966fc