Skip to content

Commit

Permalink
release markers and extend buffer when reading pairs
Browse files Browse the repository at this point in the history
we would _like_ the sbuff functions to automatically extend the
buffers at a low water marker.  But instead that has to be done
manually.
  • Loading branch information
alandekok committed Nov 1, 2023
1 parent 59eb9ed commit a3e87c6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib/server/users_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static inline void line_error_marker(char const *src_file, int src_line,
end = fr_sbuff_adv_to_chr(sbuff, SIZE_MAX, '\n');
if (!end) end = fr_sbuff_end(sbuff);
fr_sbuff_set(sbuff, &start);
fr_sbuff_marker_release(&start);

fr_log_marker(LOG_DST, L_ERR, src_file, src_line,
fr_sbuff_start(sbuff), end - fr_sbuff_start(sbuff),
Expand All @@ -71,6 +72,7 @@ static inline void line_error_marker_adj(char const *src_file, int src_line,
end = fr_sbuff_adv_to_chr(sbuff, SIZE_MAX, '\n');
if (!end) end = fr_sbuff_end(sbuff);
fr_sbuff_set(sbuff, &start);
fr_sbuff_marker_release(&start);

fr_log_marker(LOG_DST, L_ERR, src_file, src_line,
fr_sbuff_current(sbuff), end - fr_sbuff_current(sbuff),
Expand Down Expand Up @@ -301,6 +303,8 @@ int pairlist_read(TALLOC_CTX *ctx, fr_dict_t const *dict, char const *file, PAIR
bool leading_spaces;
PAIR_LIST *t;

fr_sbuff_extend_lowat(NULL, &sbuff, 1024);

/*
* If the line is empty or has only comments,
* then we don't care about leading spaces.
Expand Down Expand Up @@ -389,6 +393,8 @@ int pairlist_read(TALLOC_CTX *ctx, fr_dict_t const *dict, char const *file, PAIR
comma = false;

check_item:
fr_sbuff_extend_lowat(NULL, &sbuff, 1024);

/*
* Skip spaces before the item, and allow the
* check list to end on comment or LF.
Expand Down Expand Up @@ -521,6 +527,8 @@ int pairlist_read(TALLOC_CTX *ctx, fr_dict_t const *dict, char const *file, PAIR
comma = false;

reply_item:
fr_sbuff_extend_lowat(NULL, &sbuff, 1024);

/*
* Reply items start with spaces. If there's no
* spaces, then the current entry is done. Add
Expand Down

0 comments on commit a3e87c6

Please sign in to comment.