From: Frank Lichtenheld Date: Sun, 14 Sep 2025 17:46:29 +0000 (+0200) Subject: manage: Change command_line_* API to use size_t for lengths X-Git-Tag: v2.7_beta2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5759a838ee630409b44206a60a599041a23c1190;p=thirdparty%2Fopenvpn.git manage: Change command_line_* API to use size_t for lengths The used functions already expect this. Change-Id: Ifc183e42b190e19e1d8c351d1cd460a038626e63 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering 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 --- diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 114e4c65f..4decdfe97 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -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); diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 0bce25e50..7c189ba7e 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -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);