diff mbox

[libnftnl] Rename xfree() to libnftnl_xfree() to avoid symbol naming conflict

Message ID 20140819220236.GA7136@salvia
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

Pablo Neira Ayuso Aug. 19, 2014, 10:02 p.m. UTC
On Sat, Aug 16, 2014 at 03:39:49PM +0200, Thomas Petazzoni wrote:
> When ELF binaries and shared libraries are used, the internal
> functions of libnftnl such as xfree() are not visible to the outside
> world (their visibility is 'hidden'). Therefore, the fact that other
> programs (especially nftables) may have symbols with the same name
> does not cause any problem.
> 
> However, when doing static linking on a non-ELF platform (such as
> Blackfin, which uses the FLAT binary format), there is no way of
> encoding this visibility. Therefore, the xfree() symbols of libnftnl
> becomes visible to the outside world, causing a conflict with the
> xfree() symbol defined by nftables.
> 
> To solve this, this patch renames the libnftnl xfree() function to
> libnftnl_xfree().

Would this small patch solve your problem too?

Comments

Thomas Petazzoni Aug. 20, 2014, 12:07 p.m. UTC | #1
Dear Pablo Neira Ayuso,

On Wed, 20 Aug 2014 00:02:36 +0200, Pablo Neira Ayuso wrote:

> > To solve this, this patch renames the libnftnl xfree() function to
> > libnftnl_xfree().
> 
> Would this small patch solve your problem too?

Yes, I believe this would work as well, as long as this definition
doesn't get exposed to public headers of the library.

Thanks!

Thomas
Jan Engelhardt Aug. 20, 2014, 1 p.m. UTC | #2
On Wednesday 2014-08-20 00:02, Pablo Neira Ayuso wrote:

>On Sat, Aug 16, 2014 at 03:39:49PM +0200, Thomas Petazzoni wrote:
>> [...] the xfree() symbols of libnftnl
>> becomes visible to the outside world, causing a conflict with the
>> xfree() symbol defined by nftables.
>> 
>> To solve this, this patch renames the libnftnl xfree() function to
>> libnftnl_xfree().
>
>Would this small patch solve your problem too?
>
>[non-inline attachment]

It would, but why add the redundant cast?
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso Aug. 20, 2014, 1:22 p.m. UTC | #3
On Wed, Aug 20, 2014 at 03:00:18PM +0200, Jan Engelhardt wrote:
> On Wednesday 2014-08-20 00:02, Pablo Neira Ayuso wrote:
> 
> >On Sat, Aug 16, 2014 at 03:39:49PM +0200, Thomas Petazzoni wrote:
> >> [...] the xfree() symbols of libnftnl
> >> becomes visible to the outside world, causing a conflict with the
> >> xfree() symbol defined by nftables.
> >> 
> >> To solve this, this patch renames the libnftnl xfree() function to
> >> libnftnl_xfree().
> >
> >Would this small patch solve your problem too?
> >
> >[non-inline attachment]
> 
> It would, but why add the redundant cast?

free() makes gcc spot a warning when called with const objects.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/internal.h b/src/internal.h
index e76a5cb..c8dea7e 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -16,6 +16,8 @@ 
 #include <libnftnl/common.h>
 #include <linux/netfilter/nf_tables.h>
 
+#define xfree(ptr)	free((void *)ptr);
+
 #define BASE_DEC 10
 #define BASE_HEX 16
 
@@ -144,8 +146,6 @@  int nft_event_footer_snprintf(char *buf, size_t bufsize,
 			      uint32_t format, uint32_t flags);
 int nft_event_footer_fprintf(FILE *fp, uint32_t format, uint32_t flags);
 
-void xfree(const void *ptr);
-
 struct expr_ops;
 
 struct nft_rule_expr {
diff --git a/src/utils.c b/src/utils.c
index 1878390..96c8bf2 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -180,11 +180,6 @@  int nft_str2verdict(const char *verdict, int *verdict_num)
 	return -1;
 }
 
-void xfree(const void *ptr)
-{
-	free((void *)ptr);
-}
-
 int nft_fprintf(FILE *fp, void *obj, uint32_t type, uint32_t flags,
 		int (*snprintf_cb)(char *buf, size_t bufsiz, void *obj,
 				   uint32_t type, uint32_t flags))