Skip to content

Commit

Permalink
fixup! fixup! http: Use libhtp-rs.
Browse files Browse the repository at this point in the history
  • Loading branch information
catenacyber committed Jan 30, 2025
1 parent 4103247 commit 81c8b60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions rust/htp/src/c_api/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ pub unsafe extern "C" fn htp_header_value_ptr(header: *const Header) -> *const u
///
/// tx: Header pointer.
///
/// Returns the length or -1 on error.
/// Returns the length or 0 on a NULL pointer.
/// # Safety
/// When calling this method, you have to ensure that header is either properly initialized or NULL
#[no_mangle]
pub unsafe extern "C" fn htp_header_value_len(header: *const Header) -> isize {
pub unsafe extern "C" fn htp_header_value_len(header: *const Header) -> usize {
header
.as_ref()
.map(|header| isize::try_from(header.value.len()).unwrap_or(-1))
.unwrap_or(-1)
.map(|header| header.value.len())
.unwrap_or(0)
}
4 changes: 2 additions & 2 deletions src/log-httplog.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void LogHttpLogCustom(LogHttpLogThread *aft, htp_tx_t *tx, const SCTime_t
h_request_hdr = htp_tx_request_header(tx, node->data);
if (h_request_hdr != NULL) {
datalen = node->maxlen;
if (datalen == 0 || datalen > (size_t)htp_header_value_len(h_request_hdr)) {
if (datalen == 0 || datalen > htp_header_value_len(h_request_hdr)) {
datalen = htp_header_value_len(h_request_hdr);
}
PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
Expand Down Expand Up @@ -283,7 +283,7 @@ static void LogHttpLogCustom(LogHttpLogThread *aft, htp_tx_t *tx, const SCTime_t
}
if (h_response_hdr != NULL) {
datalen = node->maxlen;
if (datalen == 0 || datalen > (size_t)htp_header_value_len(h_response_hdr)) {
if (datalen == 0 || datalen > htp_header_value_len(h_response_hdr)) {
datalen = htp_header_value_len(h_response_hdr);
}
PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
Expand Down

0 comments on commit 81c8b60

Please sign in to comment.