GUACAMOLE-629: Define constant for maximum blob size.
diff --git a/src/libguac/encode-jpeg.c b/src/libguac/encode-jpeg.c
index 1aeb23b..8e145d8 100644
--- a/src/libguac/encode-jpeg.c
+++ b/src/libguac/encode-jpeg.c
@@ -59,7 +59,7 @@
/**
* The output buffer.
*/
- unsigned char buffer[6048];
+ unsigned char buffer[GUAC_PROTOCOL_BLOB_MAX_LENGTH];
} guac_jpeg_destination_mgr;
diff --git a/src/libguac/encode-png.c b/src/libguac/encode-png.c
index 7d4b6c7..20d2f5d 100644
--- a/src/libguac/encode-png.c
+++ b/src/libguac/encode-png.c
@@ -56,7 +56,7 @@
/**
* Buffer of pending PNG data.
*/
- char buffer[6048];
+ char buffer[GUAC_PROTOCOL_BLOB_MAX_LENGTH];
/**
* The number of bytes currently stored in the buffer.
diff --git a/src/libguac/encode-webp.c b/src/libguac/encode-webp.c
index 5c2237d..43c5a00 100644
--- a/src/libguac/encode-webp.c
+++ b/src/libguac/encode-webp.c
@@ -52,7 +52,7 @@
/**
* Buffer of pending WebP data.
*/
- char buffer[6048];
+ char buffer[GUAC_PROTOCOL_BLOB_MAX_LENGTH];
/**
* The number of bytes currently stored in the buffer.
diff --git a/src/libguac/guacamole/protocol-constants.h b/src/libguac/guacamole/protocol-constants.h
index 6ad7bf1..afa67bb 100644
--- a/src/libguac/guacamole/protocol-constants.h
+++ b/src/libguac/guacamole/protocol-constants.h
@@ -40,5 +40,14 @@
*/
#define GUACAMOLE_PROTOCOL_VERSION "VERSION_1_1_0"
+/**
+ * The maximum number of bytes that should be sent in any one blob instruction
+ * to ensure the instruction does not exceed the maximum allowed instruction
+ * size.
+ *
+ * @see GUAC_INSTRUCTION_MAX_LENGTH
+ */
+#define GUAC_PROTOCOL_BLOB_MAX_LENGTH 6048
+
#endif
diff --git a/src/libguac/raw_encoder.c b/src/libguac/raw_encoder.c
index 9086a37..98024cd 100644
--- a/src/libguac/raw_encoder.c
+++ b/src/libguac/raw_encoder.c
@@ -129,8 +129,8 @@
/* Determine size of blob to be written */
int chunk_size = remaining;
- if (chunk_size > 6048)
- chunk_size = 6048;
+ if (chunk_size > GUAC_PROTOCOL_BLOB_MAX_LENGTH)
+ chunk_size = GUAC_PROTOCOL_BLOB_MAX_LENGTH;
/* Send audio data */
guac_protocol_send_blob(socket, stream, current, chunk_size);