]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftp: reduce size of some struct fields
authorDaniel Stenberg <daniel@haxx.se>
Wed, 22 Oct 2025 11:22:21 +0000 (13:22 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 22 Oct 2025 13:55:05 +0000 (15:55 +0200)
Closes #19191

lib/ftp.c
lib/ftp.h

index 1d33a96b10e87b684aaf1717b985b6d440467f04..cd8903e1b3dcc2f91f93232f00d0623c65a1cc6b 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -4169,6 +4169,8 @@ static size_t numof_slashes(const char *str)
   return num;
 }
 
+#define FTP_MAX_DIR_DEPTH 1000
+
 /***********************************************************************
  *
  * ftp_parse_url_path()
@@ -4242,7 +4244,7 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data,
       /* number of entries to allocate for the 'dirs' array */
       size_t dirAlloc = numof_slashes(rawPath);
 
-      if(dirAlloc >= 1000)
+      if(dirAlloc >= FTP_MAX_DIR_DEPTH)
         /* suspiciously deep dir hierarchy */
         return CURLE_URL_MALFORMAT;
 
index 76326331b48f860c94601c7aa8eba05eee6a557d..d06738f113926115827e5a58f724c549de8dc384 100644 (file)
--- a/lib/ftp.h
+++ b/lib/ftp.h
@@ -141,14 +141,18 @@ struct ftp_conn {
   curl_off_t known_filesize; /* file size is different from -1, if wildcard
                                 LIST parsing was done and wc_statemach set
                                 it */
-  int dirdepth;  /* number of entries used in the 'dirs' array */
-  int cwdcount;     /* number of CWD commands issued */
   int count1; /* general purpose counter for the state machine */
   int count2; /* general purpose counter for the state machine */
   int count3; /* general purpose counter for the state machine */
-  ftpstate state; /* always use ftp.c:state() to change state! */
-  ftpstate state_saved; /* transfer type saved to be reloaded after data
-                           connection is established */
+  unsigned short dirdepth;  /* number of entries used in the 'dirs' array,
+                               < FTP_MAX_DIR_DEPTH */
+  unsigned short cwdcount;  /* number of CWD commands issued,
+                               < FTP_MAX_DIR_DEPTH */
+  unsigned char state; /* (ftpstate enum) always use ftp.c:state() to change
+                          state! */
+  unsigned char state_saved; /* (ftpstate enum) transfer type saved to be
+                                reloaded after data connection is
+                                established */
   unsigned char use_ssl;   /* if AUTH TLS is to be attempted etc, for FTP or
                               IMAP or POP3 or others! (type: curl_usessl)*/
   unsigned char ccc;       /* ccc level for this connection */