Skip to contentSkip to conversation

keyingmaterialexporter.c: include strings.h

PATCH In review Antonio Quartulli 2 participants 4 messages Feb 3, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 keyingmaterialexporter.c: include strings.h

strcasecmp() was initially declared in string.h and subsequently moved to strings.h. For historical reasons it still exists in string.h, but would require _DEFAULT_SOURCE to be defined.

Due to the above, just include strings.h as currently dictated by the manpage.

Fixes the following warning:

keying-material-exporter-demo/keyingmaterialexporter.c:155:14: warning: implicit declaration of function strncasecmp’; did you mean ‘strncmp’? [-Wimplicit-function-declaration]

  155 |         if (!strncasecmp(objbuf, "CN", 2))
      |              ^~~~~~~~~~~
      |              strncmp
---
 .../keying-material-exporter-demo/keyingmaterialexporter.c       | 1 +
 1 file changed, 1 insertion(+)
sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c +1 -0
index 1f47cb35..e2820418 100644
@@ -29,6 +29,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <strings.h>
 #include <stdlib.h>
 
 #include "openvpn-plugin.h"
Signature · 1 line
2.34.1
#1 lore raw

Hi,

Quoted 6 lines · Antonio Quartulli

strcasecmp() was initially declared in string.h and subsequently moved to strings.h. For historical reasons it still exists in string.h, but would require _DEFAULT_SOURCE to be defined.

Due to the above, just include strings.h as currently dictated by the manpage.

If we include strings.h, do we still need string.h then?

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#2 lore raw

Hi,

Quoted 11 lines · Gert Doering

Hi,

Quoted 6 lines · Antonio Quartulli

strcasecmp() was initially declared in string.h and subsequently moved to strings.h. For historical reasons it still exists in string.h, but would require _DEFAULT_SOURCE to be defined.

Due to the above, just include strings.h as currently dictated by the manpage.

If we include strings.h, do we still need string.h then?

Yes, because the file also uses strlen() and strncmp() (declared in string.h)

Regards,

Signature · 1 line
Antonio Quartulli
Acked-by on v1 1/1
#3 lore raw
In reply to Antonio Quartulli

FreeBSD manpage confirms that <strings.h> should be used. Insanity, but well.

Your patch has been applied to the master and release/2.5 branch (bugfix, even if not very critical).

commit d93a2b6160759d42d3fbaecc7fc868a7120221ef (master) commit 2d31bf20dcffaab00a677bab06c8fe3816b6605b (release/2.5)

Author: Antonio Quartulli
Date:   Thu Feb 3 09:26:20 2022 +0100
     keyingmaterialexporter.c: include strings.h

     Signed-off-by: Antonio Quartulli <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg23702.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering