Browse code

Improve documentation on user/password requirement and unicodize function

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20221215190143.2107896-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25733.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 4b6854881c36e16054878e0467ef87d925e20cae)

Arne Schwabe authored on 2022/12/16 04:01:39
Showing 2 changed files
... ...
@@ -74,6 +74,7 @@ struct user_pass
74 74
 #else
75 75
 #define USER_PASS_LEN 128
76 76
 #endif
77
+    /* Note that username and password are expected to be null-terminated */
77 78
     char username[USER_PASS_LEN];
78 79
     char password[USER_PASS_LEN];
79 80
 };
... ...
@@ -143,6 +143,19 @@ my_strupr(char *str)
143 143
     }
144 144
 }
145 145
 
146
+/**
147
+ * This function expects a null-terminated string in src and will
148
+ * copy it (including the terminating NUL byte),
149
+ * alternating it with 0 to dst.
150
+ *
151
+ * This basically will transform a ASCII string into valid UTF-16.
152
+ * Characters that are 8bit in src, will get the same treatment, resulting in
153
+ * invalid or wrong unicode code points.
154
+ *
155
+ * @note the function will blindly assume that dst has double
156
+ * the space of src.
157
+ * @return  the length of the number of bytes written to dst
158
+ */
146 159
 static int
147 160
 unicodize(char *dst, const char *src)
148 161
 {