Skip to content

Commit

Permalink
Define maximum yenc part size as constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Safihre committed Apr 17, 2023
1 parent c96089c commit ee3388f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/sabctools.h
Expand Up @@ -22,6 +22,6 @@
#include <string.h>

/* Version information */
#define SABCTOOLS_VERSION "7.0.0"
#define SABCTOOLS_VERSION "7.0.1"

PyMODINIT_FUNC PyInit_sabctools(void);
2 changes: 1 addition & 1 deletion src/yenc.cc
Expand Up @@ -148,7 +148,7 @@ PyObject* yenc_decode(PyObject* self, PyObject* Py_bytesarray_obj) {

// Get the size and sanity check the values
part_size = part_end - part_begin + 1;
if(part_end > part_begin && part_size > 0 && part_size <= 10*1024*1024) {
if(part_end > part_begin && part_size > 0 && part_size <= YENC_MAX_PART_SIZE) {
part_begin = part_begin - 1;
} else {
part_size = part_end = part_begin = 0;
Expand Down
5 changes: 4 additions & 1 deletion src/yenc.h
Expand Up @@ -32,9 +32,12 @@
#define YENC_CR 0x0d
#define YENC_LF 0x0a

/* The =yend line cannot be crazy long*/
/* The =yend line cannot be crazy long */
#define YENC_MAX_TAIL_BYTES 256

/* Prevent strange yEnc sizes */
#define YENC_MAX_PART_SIZE 10*1024*1024

/* Functions */
PyObject* yenc_decode(PyObject *, PyObject*);
PyObject* yenc_encode(PyObject *, PyObject*);
Expand Down

0 comments on commit ee3388f

Please sign in to comment.