Skip to content
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

doxygen2man: Fix a couple of covscan-detected errors #425

Merged
merged 2 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doxygen2man/cstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ cstring_t cstring_append_chars(cstring_t cstring, const char *newstring)
h = (struct cstring_header *)(char *)cstring;
h->allocated = new_allocsize;
}
strncat(h->the_string, newstring, h->allocated-1);
strncat(h->the_string, newstring, h->allocated - h->used -1);
h->used += strlen(newstring);
return cstring;
}
Expand Down
11 changes: 8 additions & 3 deletions doxygen2man/doxygen2man.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#define _DEFAULT_SOURCE
#define _BSD_SOURCE
#define _GNU_SOURCE
#define _XOPEN_SOURCE
#define _XOPEN_SOURCE_EXTENDED
#include <stdlib.h>
Expand All @@ -33,6 +34,7 @@
#include <qb/qblist.h>
#include <qb/qbmap.h>
#include "cstring.h"

/*
* This isn't a maximum size, it just defines how long a parameter
* type can get before we decide it's not worth lining everything up.
Expand Down Expand Up @@ -498,10 +500,13 @@ static char *allcaps(const char *name)
static char buffer[4096] = {'\0'};
size_t i;

for (i=0; i< strlen(name); i++) {
buffer[i] = toupper(name[i]);
if (name) {
size_t len = strnlen(name, 4096);
for (i=0; i< len; i++) {
buffer[i] = toupper(name[i]);
}
buffer[len] = '\0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW you can also shave off the len declaration by using buffer[i] = 0 here (if this is your thing). :)

}
buffer[strlen(name)] = '\0';
return buffer;
}

Expand Down