Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

I'd like you to do a code review.
Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2382?usp=email

to review the following change.


Change subject: domain_helper: split out the letter and digit check
......................................................................

domain_helper: split out the letter and digit check

The dns updown runner needs the letter, digit and non-ASCII part of
the domain name check for interface names, which allow different
punctuation.

Add doxygen comments to the helpers while there.

Change-Id: Id44ac5881f57088ae75aa40dcfc72aba0dc94f4e
Signed-off-by: Heiko Hund <[email protected]>
---
M src/openvpn/domain_helper.h
1 file changed, 32 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/82/2382/1

diff --git a/src/openvpn/domain_helper.h b/src/openvpn/domain_helper.h
index be9c116..e4e7fc7 100644
--- a/src/openvpn/domain_helper.h
+++ b/src/openvpn/domain_helper.h
@@ -21,15 +21,45 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */

+/**
+ * Check if a character is an ASCII letter or digit, or a non-ASCII byte
+ *
+ * @param  c        character to check
+ *
+ * @return bool to indicate if the character is one of those
+ */
 static inline bool
-is_allowed_domain_ascii(unsigned char c)
+is_alnum_or_non_ascii(unsigned char c)
 {
     return (c >= 'A' && c <= 'Z')
            || (c >= 'a' && c <= 'z')
            || (c >= '0' && c <= '9')
-           || c == '.' || c == '-' || c == '_' || c >= 0x80;
+           || c >= 0x80;
 }

+/**
+ * Check if a character is allowed in a domain name
+ *
+ * Besides letters and digits, dots, dashes and underscores are allowed.
+ * Non-ASCII bytes are accepted as well, so that UTF-8 encoded names pass.
+ *
+ * @param  c        character to check
+ *
+ * @return bool to indicate if the character is allowed
+ */
+static inline bool
+is_allowed_domain_ascii(unsigned char c)
+{
+    return is_alnum_or_non_ascii(c) || c == '.' || c == '-' || c == '_';
+}
+
+/**
+ * Check if a domain name contains only allowed characters
+ *
+ * @param  domain   NUL terminated domain name
+ *
+ * @return bool to indicate if the domain name is valid
+ */
 static inline bool
 validate_domain(const char *domain)
 {

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2382?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id44ac5881f57088ae75aa40dcfc72aba0dc94f4e
Gerrit-Change-Number: 2382
Gerrit-PatchSet: 1
Gerrit-Owner: Heiko Hund <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to