Skip to content

Commit 638a158

Browse files
author
Rob Sanders
committed
Replace strchrnul with possibly 2 calls to strchr (issue #78), update spec
1 parent 01db2ef commit 638a158

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

libcli.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2515,6 +2515,16 @@ int cli_int_unregister_buildmode_command(struct cli_def *cli, const char *comman
25152515
return cli_int_unregister_command_core(cli, command, CLI_BUILDMODE_COMMAND);
25162516
}
25172517

2518+
// recoded to find first '\v', otherwise first NULL, instead of using GNU extension strchrnul()
2519+
char *local_strchrnul(const char *src, char target)
2520+
{
2521+
char *found=NULL;
2522+
if ((found=strchr(src, target))) {
2523+
return found;
2524+
}
2525+
return strchr(src,'\0');
2526+
}
2527+
25182528
struct cli_command *cli_int_register_buildmode_command(struct cli_def *cli, struct cli_command *parent,
25192529
const char *command,
25202530
int (*callback)(struct cli_def *cli, const char *, char **, int),
@@ -2535,7 +2545,7 @@ struct cli_command *cli_int_register_buildmode_command(struct cli_def *cli, stru
25352545
c->command_type = CLI_BUILDMODE_COMMAND;
25362546
c->privilege = privilege;
25372547
c->mode = mode;
2538-
if (help && !(c->help = strndup(help, strchrnul(help, '\v') - help))) {
2548+
if (help && !(c->help = strndup(help, local_strchrnul(help, '\v') - help))) {
25392549
free(c->command);
25402550
free(c);
25412551
return NULL;

libcli.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ rm -rf $RPM_BUILD_ROOT
6767
%defattr(-, root, root)
6868

6969
%changelog
70-
* Wed Dec 17 2023 Rob Sanders <rsanders@forcepointgov.com> 1.10.8
70+
* Wed Dec 27 2023 Rob Sanders <rsanders@forcepointgov.com> 1.10.8
71+
- Replace strchrnul() with possibly 2 calls to strchr() (issue #78)
72+
73+
* Sun Dec 17 2023 Rob Sanders <rsanders@forcepointgov.com> 1.10.8
7174
- Changed from strcasecmp to strcmp in cli_loop() to do case sensitive comparison for <tab> completion (issue #91)
75+
7276
* Fri Dec 2 2022 Rob Sanders <rsanders@forcepointgov.com> 1.10.8
7377
- Added regular callback fixes to ensure callback fires every # seconds regardless of input - code provided by github user JereLeppanen initially on 27Apr2022(issue #76)
78+
7479
* Thu Dec 1 2022 Rob Sanders <rsanders@forcepointgov.com> 1.10.8
7580
- Add backward compatibility for LIBCLI versions numbers (issue #85)
76-
7781
- applied fixes for misspellings on LIBCLI version #defines (issue #75) - fix provided on github by belge-sel on 19Sep2021
7882
- Fix for printing (issue #79) where text left in buffer (from call to cli_bufprint for example) is discarded instead of preserved. Code provided on github by JereLeppanen on 27Apr2021
7983

0 commit comments

Comments
 (0)