-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
app_rpt.c: Refactor handle_link_data() and handle_remote_data() #474
base: master
Are you sure you want to change the base?
Conversation
if (l->mode > 1) | ||
continue; /* dont report local modes */ | ||
if (l->linklist[0]) { | ||
buffer_size += (strlen(l->linklist) + strlen(l->name) + 3); /*+3: 2 for the commas, 1 for mode, 1 extra as the first pass has no comma*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about needing "3". You need 1 for the mode and 1 more for either a comma (if more nodes follow) or the end-of-line (if this was the last node).
Note: if looks like RPT_ALINKS includes an extra character so we do need 3 (mode, keyed/unkeyed, and comma/EOL)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a comma appended to the end of the full list except for the first pass:
T123, "stuff from the linklist" , T345, "stuff from the next link list" -> 2 commas if more than 1 link (between T123 and T345) other wise only 1 comma.
Maybe my comment about 1 extra comma for the first pass is not clear enough, we will be 1 char larger than we need.
update sprintf to snprintf rpt_link.c: Calculate buffer size and malloc buffers. add function __get_buffer_size() to calculate buffer size required. add node count to __mklinklist() add macro for OBUFSIZE and BUFSIZE calculation elminate finddelim() call as __mklinklist now counts links
ff1ee3c
to
9f1050a
Compare
I will squash into a single commit once we are done reviewing it. |
fix up count in __mklinklist
Fixing up finddelim may not be possible. I think some of the instances are searching through non null terminated values (but I can't be sure right now). With numbers like 3 in the limit while strs[100]. |
I'll take a look at the finddelim call sites tomorrow. |
FYI : in
So, when needed, we can use |
Looks like chan_echolink.c, chan_tlb.c, and chan_voter have their own copy/version of |
I saw that when I was making the move. |
0d63fd5
to
76c4416
Compare
This is a follow on to PR #470 which should not be delayed. Intent is to clean up the stuff I notice while hunting down the truncated message.
Eliminate copy of malloc
char*
to fixed lengthchar*
update
sprintf()
tosnprintf()
rpt_link.c: Calculate buffer size and malloc buffers. add function __get_buffer_size() to calculate buffer size required. add node count to __mklinklist()
add macro for OBUFSIZE and BUFSIZE calculation
eliminate
finddelim()
call as__mklinklist()
now counts links.