summaryrefslogtreecommitdiff
path: root/net/proftpd/patches/patch-ac
blob: 2f8048a29df308de024563c5c2397326690486a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$NetBSD: patch-ac,v 1.6 2006/11/23 11:57:07 adrianp Exp $

--- src/main.c.orig	2006-03-15 19:41:01.000000000 +0000
+++ src/main.c
@@ -116,6 +116,8 @@ static unsigned char have_dead_child = F
 
 static char sbuf[PR_TUNABLE_BUFFER_SIZE] = {'\0'};
 
+#define PR_DEFAULT_CMD_BUFSZ    512
+
 static char **Argv = NULL;
 static char *LastArgv = NULL;
 static const char *PidPath = PR_PID_FILE_PATH;
@@ -820,17 +822,24 @@ static void cmd_loop(server_rec *server,
       pr_timer_reset(TIMER_IDLE, NULL);
 
     if (cmd_buf_size == -1) {
-      long *buf_size = get_param_ptr(main_server->conf,
-        "CommandBufferSize", FALSE);
-
-      if (buf_size == NULL || *buf_size <= 0)
-        cmd_buf_size = 512;
-
-      else if (*buf_size + 1 > sizeof(buf)) {
-	pr_log_pri(PR_LOG_WARNING, "Invalid CommandBufferSize size given. "
-          "Resetting to 512.");
-	cmd_buf_size = 512;
-      }
+      int *bufsz = get_param_ptr(main_server->conf, "CommandBufferSize", FALSE);
+    if (bufsz == NULL) {
+      cmd_buf_size = PR_DEFAULT_CMD_BUFSZ;
+    }
+    else if ( bufsz <= 0 ) {
+      pr_log_pri(PR_LOG_WARNING, "invalid CommandBufferSize size (%d) "
+                 "given, resetting to default buffer size (%u)",
+		 *bufsz, (unsigned int) PR_DEFAULT_CMD_BUFSZ);
+      cmd_buf_size = PR_DEFAULT_CMD_BUFSZ;
+    } else if (*bufsz + 1 > sizeof(buf)) {
+	     pr_log_pri(PR_LOG_WARNING, "invalid CommandBufferSize size (%d) "
+			"given, using default buffer size (%u) instead",
+			*bufsz, (unsigned int) PR_DEFAULT_CMD_BUFSZ);
+	     cmd_buf_size = PR_DEFAULT_CMD_BUFSZ;
+	   } else {
+	     pr_log_debug(DEBUG1, "setting CommandBufferSize to %d", *bufsz);
+	     cmd_buf_size = (long) *bufsz;
+	   }
     }
 
     buf[cmd_buf_size - 1] = '\0';