Skip to content

Commit

Permalink
multipartheader is too big, move its content to the heap
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges committed Jan 20, 2024
1 parent 37f9b25 commit ca54b56
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/zmq.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2020-2023 Fanout, Inc.
* Copyright (C) 2024 Fastly, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -127,7 +128,7 @@ fn unsetup_spec(sock: &zmq::Socket, spec: &ActiveSpec) {
}
}

pub type MultipartHeader = ArrayVec<zmq::Message, MULTIPART_HEADERS_MAX>;
pub type MultipartHeader = Vec<zmq::Message>;

pub struct ZmqSocket {
inner: zmq::Socket,
Expand Down Expand Up @@ -184,6 +185,10 @@ impl ZmqSocket {
content: zmq::Message,
flags: i32,
) -> Result<(), zmq::Error> {
if header.len() > MULTIPART_HEADERS_MAX {
return Err(zmq::Error::EINVAL);
}

let mut headers: ArrayVec<&[u8], MULTIPART_HEADERS_MAX> = ArrayVec::new();

for part in header {
Expand Down Expand Up @@ -242,7 +247,7 @@ impl ZmqSocket {
break;
}

if header.len() == header.capacity() {
if header.len() == MULTIPART_HEADERS_MAX {
// header too large

let flags = 0;
Expand Down

0 comments on commit ca54b56

Please sign in to comment.