]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
manage: Change command_line_* API to use size_t for lengths
authorFrank Lichtenheld <frank@lichtenheld.com>
Sun, 14 Sep 2025 17:46:29 +0000 (19:46 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 15 Sep 2025 06:49:11 +0000 (08:49 +0200)
The used functions already expect this.

Change-Id: Ifc183e42b190e19e1d8c351d1cd460a038626e63
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1136
Message-Id: <20250914174638.6867-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32929.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/manage.c
src/openvpn/manage.h

index 114e4c65f9b98d0ec9a7c966bf50bc19f5f4cef0..4decdfe9786ad9b6d2db7869b38240e68351e1de 100644 (file)
@@ -2334,7 +2334,7 @@ man_read(struct management *man)
         bool processed_command = false;
 
         ASSERT(len <= (int)sizeof(buf));
-        command_line_add(man->connection.in, buf, len);
+        command_line_add(man->connection.in, buf, (size_t)len);
 
         /*
          * Reset output object
@@ -3873,7 +3873,7 @@ management_hold(struct management *man, int holdtime)
  */
 
 struct command_line *
-command_line_new(const int buf_len)
+command_line_new(const size_t buf_len)
 {
     struct command_line *cl;
     ALLOC_OBJ_CLEAR(cl, struct command_line);
@@ -3903,10 +3903,9 @@ command_line_free(struct command_line *cl)
 }
 
 void
-command_line_add(struct command_line *cl, const unsigned char *buf, const int len)
+command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len)
 {
-    int i;
-    for (i = 0; i < len; ++i)
+    for (size_t i = 0; i < len; ++i)
     {
         if (buf[i] && char_class(buf[i], (CC_PRINT | CC_NEWLINE)))
         {
@@ -3921,10 +3920,9 @@ command_line_add(struct command_line *cl, const unsigned char *buf, const int le
 const char *
 command_line_get(struct command_line *cl)
 {
-    int i;
     const char *ret = NULL;
 
-    i = buf_substring_len(&cl->buf, '\n');
+    int i = buf_substring_len(&cl->buf, '\n');
     if (i >= 0)
     {
         buf_copy_excess(&cl->residual, &cl->buf, i);
index 0bce25e50acf661652aa47a70d5fef0a15a63b11..7c189ba7e3dd6d90182e838c543dc4e83e926733 100644 (file)
@@ -80,11 +80,11 @@ struct command_line
     struct buffer residual;
 };
 
-struct command_line *command_line_new(const int buf_len);
+struct command_line *command_line_new(const size_t buf_len);
 
 void command_line_free(struct command_line *cl);
 
-void command_line_add(struct command_line *cl, const unsigned char *buf, const int len);
+void command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len);
 
 const char *command_line_get(struct command_line *cl);