Skip to content

Commit

Permalink
Revert "move extend out of users_file.c to sbuff.c"
Browse files Browse the repository at this point in the history
This reverts commit 02ec7cd.

it turns out extending things in the sbuff code causes other
problems.  So we leave some hacks in the users_file parser.
  • Loading branch information
alandekok committed Nov 1, 2023
1 parent 4ffc946 commit c283f16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/lib/server/users_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,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 @@ -391,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 @@ -523,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
10 changes: 5 additions & 5 deletions src/lib/util/sbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ size_t fr_sbuff_out_bstrncpy(fr_sbuff_t *out, fr_sbuff_t *in, size_t len)

remaining = (len - fr_sbuff_used_total(&our_in));

if (!fr_sbuff_extend_lowat(NULL, &our_in, 32)) break;
if (!fr_sbuff_extend(&our_in)) break;

chunk_len = fr_sbuff_remaining(&our_in);
if (chunk_len > remaining) chunk_len = remaining;
Expand Down Expand Up @@ -741,7 +741,7 @@ ssize_t fr_sbuff_out_bstrncpy_exact(fr_sbuff_t *out, fr_sbuff_t *in, size_t len)
ssize_t copied;

remaining = (len - fr_sbuff_used_total(&our_in));
if (remaining && !fr_sbuff_extend_lowat(NULL, &our_in, 32)) return 0;
if (remaining && !fr_sbuff_extend(&our_in)) return 0;

chunk_len = fr_sbuff_remaining(&our_in);
if (chunk_len > remaining) chunk_len = remaining;
Expand Down Expand Up @@ -788,7 +788,7 @@ size_t fr_sbuff_out_bstrncpy_allowed(fr_sbuff_t *out, fr_sbuff_t *in, size_t len
char *p;
char *end;

if (!fr_sbuff_extend_lowat(NULL, &our_in, 32)) break;
if (!fr_sbuff_extend(&our_in)) break;

p = fr_sbuff_current(&our_in);
end = CONSTRAINED_END(&our_in, len, fr_sbuff_used_total(&our_in));
Expand Down Expand Up @@ -1748,7 +1748,7 @@ size_t fr_sbuff_adv_past_allowed(fr_sbuff_t *sbuff, size_t len, bool
while (total < len) {
char *end;

if (!fr_sbuff_extend_lowat(NULL, sbuff, 32)) break;
if (!fr_sbuff_extend(sbuff)) break;

end = CONSTRAINED_END(sbuff, len, total);
p = sbuff->p;
Expand Down Expand Up @@ -1923,7 +1923,7 @@ char *fr_sbuff_adv_to_chr(fr_sbuff_t *sbuff, size_t len, char c)
char const *found;
char *end;

if (!fr_sbuff_extend_lowat(NULL, &our_sbuff, 32)) break;
if (!fr_sbuff_extend(&our_sbuff)) break;

end = CONSTRAINED_END(sbuff, len, total);
found = memchr(our_sbuff.p, c, end - our_sbuff.p);
Expand Down

0 comments on commit c283f16

Please sign in to comment.