Skip to content

Commit

Permalink
Fix possible integer overflow when serializing log_val_type. (#404)
Browse files Browse the repository at this point in the history
We can see that the "custom" entrie of the log_val_type enum is set to 999. However, when this value is serialized, it
is cast as 8bit unsigned integer which maximum value is 255.

We type the enumeration to 8bit interger and we change the value of custom to 999 (given that 999 % 256 = 231).
  • Loading branch information
cbucher authored Mar 21, 2023
1 parent 2c2d2c2 commit d5e66a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/libnuraft/log_val_type.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ limitations under the License.

namespace nuraft {

enum log_val_type {
enum log_val_type : byte {
app_log = 1,
conf = 2,
cluster_server = 3,
log_pack = 4,
snp_sync_req = 5,
custom = 999,
custom = 231,
};

}
Expand Down

0 comments on commit d5e66a0

Please sign in to comment.