summaryrefslogtreecommitdiff
path: root/net/proftpd/patches/patch-ac
blob: 9da9504f99db8c01a3af1587dedd6b67ca93edcf (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
$NetBSD: patch-ac,v 1.5 2006/11/18 14:32:58 adrianp Exp $

--- src/main.c.orig	2006-11-18 14:24:35.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,16 +822,25 @@ 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);
+      int *bufsz = get_param_ptr(main_server->conf, "CommandBufferSize",
+        FALSE);
 
-      if (buf_size == NULL || *buf_size <= 0)
-        cmd_buf_size = 512;
+      if (bufsz == NULL ||
+          *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, resetting to default buffer size (%u)",
+          *bufsz, (unsigned int) PR_DEFAULT_CMD_BUFSZ);
+	cmd_buf_size = PR_DEFAULT_CMD_BUFSZ;
 
-      else if (*buf_size + 1 > sizeof(buf)) {
-	pr_log_pri(PR_LOG_WARNING, "Invalid CommandBufferSize size given. "
-          "Resetting to 512.");
-	cmd_buf_size = 512;
+      } else {
+        pr_log_debug(DEBUG1, "setting CommandBufferSize to %d", *bufsz);
+        cmd_buf_size = (long) *bufsz;
       }
     }