Skip to content

Commit e374b22

Browse files
committed
Use correct type for oscap pcre methods
Before we using signed int for size_t which unsigned. This commit uses the correct size_t for these.
1 parent 3acb5cc commit e374b22

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/OVAL/probes/independent/textfilecontent54_probe.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,14 @@ struct pfdata {
123123
static int process_file(const char *prefix, const char *path, const char *file, struct pfdata *pfd, oval_schema_version_t over, struct oscap_list *blocked_paths)
124124
{
125125
int ret = 0, path_len, file_len, cur_inst = 0, fd = -1, substr_cnt,
126-
buf_size = 0, buf_used = 0, ofs = 0, buf_inc = 4096, instance_count = 0,
126+
buf_size = 0, buf_used = 0, buf_inc = 4096, instance_count = 0,
127127
want_instance = 1, negative_instance_value = 0;
128128
char **substrs = NULL;
129129
char *whole_path = NULL, *whole_path_with_prefix = NULL, *buf = NULL;
130130
SEXP_t *next_inst = NULL, *items = SEXP_list_new(NULL), *instance_value_list = NULL,
131131
*instance_value = NULL;
132132
struct stat st;
133+
size_t ofs = 0;
133134

134135

135136
if (file == NULL)

src/OVAL/probes/independent/textfilecontent_probe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static int process_file(const char *prefix, const char *path, const char *filena
197197

198198
int cur_inst = 0;
199199
char line[4096];
200-
int ofs = 0;
200+
size_t ofs = 0;
201201

202202
while (fgets(line, sizeof(line), fp) != NULL) {
203203
substr_cnt = oscap_pcre_get_substrings(line, &ofs, re, 1, &substrs);

src/common/oscap_pcre.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void oscap_pcre_set_match_limit_recursion(oscap_pcre_t *opcre, unsigned long lim
131131
}
132132

133133
int oscap_pcre_exec(const oscap_pcre_t *opcre, const char *subject,
134-
int length, int startoffset, oscap_pcre_options_t options,
134+
size_t length, size_t startoffset, oscap_pcre_options_t options,
135135
int *ovector, int ovecsize)
136136
{
137137
int rc = 0;
@@ -163,7 +163,7 @@ void oscap_pcre_free(oscap_pcre_t *opcre)
163163
}
164164
}
165165

166-
int oscap_pcre_get_substrings(char *str, int *ofs, oscap_pcre_t *re, int want_substrs, char ***substrings) {
166+
int oscap_pcre_get_substrings(char *str, size_t *ofs, oscap_pcre_t *re, int want_substrs, char ***substrings) {
167167
int i, ret, rc;
168168
int ovector[60], ovector_len = sizeof (ovector) / sizeof (ovector[0]);
169169
char **substrs;

src/common/oscap_pcre.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ oscap_pcre_t* oscap_pcre_compile(const char *pattern, oscap_pcre_options_t optio
7373
* negative error code on failure
7474
*/
7575
int oscap_pcre_exec(const oscap_pcre_t *opcre, const char *subject,
76-
int length, int startoffset, oscap_pcre_options_t options,
76+
size_t length, size_t startoffset, oscap_pcre_options_t options,
7777
int *ovector, int ovecsize);
7878

7979
/**
@@ -101,7 +101,7 @@ void oscap_pcre_set_match_limit_recursion(oscap_pcre_t *opcre, unsigned long lim
101101
* @return count of matched substrings, 0 if no match
102102
* negative value on failure
103103
*/
104-
int oscap_pcre_get_substrings(char *str, int *ofs, oscap_pcre_t *re, int want_substrs, char ***substrings);
104+
int oscap_pcre_get_substrings(char *str, size_t *ofs, oscap_pcre_t *re, int want_substrs, char ***substrings);
105105

106106
/**
107107
* Free the error message returned by oscap_pcre_compile. DON'T USE REGULAR free()!

0 commit comments

Comments
 (0)