Browse Source

- bugfix, potential segfault problem in result rendering

pull/3/head
Andreas Romeyke 4 years ago
parent
commit
5459ef3332
  1. 18
      src/helper/check_helper.c
  2. 8
      src/helper/check_renderer.c

18
src/helper/check_helper.c

@ -24,14 +24,18 @@ char * secstrcat (char * dest, const char * src, int maxsize) {
fprintf(stderr, "internal error, dest is NULL!\n");
exit(EXIT_FAILURE);
}
int destsize = strlen(dest);
int srclen = strlen(src);
//fprintf(stderr, "1dest='%s' , src='%s', destsize=%i, srclen=%i\n", dest, src, destsize, srclen);
if (destsize+srclen < maxsize) {
strcat( dest, src);
if (NULL == src) {
dest="";
} else {
int destsize = strlen(dest);
int srclen = strlen(src);
//fprintf(stderr, "1dest='%s' , src='%s', destsize=%i, srclen=%i\n", dest, src, destsize, srclen);
if (destsize+srclen < maxsize) {
strcat( dest, src);
}
destsize = strlen(dest);
//fprintf(stderr, "2dest='%s' , src='%s', destsize=%i, srclen=%i\n", dest, src, destsize, srclen);
}
//destsize = strlen(dest);
//fprintf(stderr, "2dest='%s' , src='%s', destsize=%i, srclen=%i\n", dest, src, destsize, srclen);
return dest;
}

8
src/helper/check_renderer.c

@ -82,7 +82,7 @@ const char * renderer_debug ( ret_t ret ) {
}
retmsg_t * startp = ret.returnmsg;
int c = 0;
while (NULL != startp && c < ret.count) {
while (NULL != startp && NULL != startp->rm_msg && c < ret.count) {
switch (startp->rm_type) {
case rm_rule: secstrcat( res, ANSI_NORMAL , 1024); break;
case rm_tag: secstrcat( res, ANSI_BOLD , 1024); break;
@ -111,7 +111,7 @@ const char * renderer_default ( ret_t ret ) {
}
retmsg_t * startp = ret.returnmsg;
int c = 0;
while (NULL != startp && c < ret.count) {
while (NULL != startp && NULL != startp->rm_msg && c < ret.count) {
secstrcat(res, startp->rm_msg, 1024);
startp++;
c++;
@ -132,7 +132,7 @@ const char * renderer_ansi ( ret_t ret ) {
}
retmsg_t * startp = ret.returnmsg;
int c = 0;
while (NULL != startp && c < ret.count) {
while (NULL != startp && NULL != startp->rm_msg && c < ret.count) {
switch (startp->rm_type) {
case rm_rule: secstrcat( res, ANSI_NORMAL , 1024); break;
case rm_tag: secstrcat( res, ANSI_BOLD , 1024); break;
@ -165,7 +165,7 @@ const char * renderer_xml ( ret_t ret ) {
}
retmsg_t * startp = ret.returnmsg;
int c = 0;
while (NULL != startp && c < ret.count) {
while (NULL != startp && NULL != startp->rm_msg && c < ret.count) {
switch (startp->rm_type) {
case rm_rule: secstrcat( res, "<rule>" , 1024); break;
case rm_tag: secstrcat( res, "<tag>" , 1024); break;

Loading…
Cancel
Save