mirror of
https://github.com/xroche/httrack.git
synced 2026-07-12 20:07:43 +03:00
Compare commits
3 Commits
master
...
drop-swf-j
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48c4e57a4e | ||
|
|
84ba3044f7 | ||
|
|
f73b352b82 |
@@ -213,20 +213,6 @@ const char *strjoker_nomemo(const char *chaine, const char *joker, LLint *size,
|
||||
return strjoker_rec(&memo, chaine, joker, size, size_flag);
|
||||
}
|
||||
|
||||
/* Test-only: strjoker() reporting the work-budget steps spent and the cap, so a
|
||||
self-test can prove the budget bounds a hostile pattern's work. */
|
||||
const char *strjoker_steps(const char *chaine, const char *joker,
|
||||
size_t *nsteps_out, size_t *maxsteps_out) {
|
||||
size_t nsteps = 0;
|
||||
const char *r = strjoker_bounded(chaine, joker, NULL, NULL, &nsteps);
|
||||
|
||||
if (nsteps_out != NULL)
|
||||
*nsteps_out = nsteps;
|
||||
if (maxsteps_out != NULL)
|
||||
*maxsteps_out = STRJOKER_MAXSTEPS;
|
||||
return r;
|
||||
}
|
||||
|
||||
static const char *strjoker_impl(const strjoker_memo *memo, const char *chaine,
|
||||
const char *joker, LLint *size,
|
||||
int *size_flag) {
|
||||
|
||||
@@ -52,10 +52,6 @@ HTS_INLINE const char *strjoker(const char *chaine, const char *joker, LLint * s
|
||||
oracle for the memoized matcher. */
|
||||
const char *strjoker_nomemo(const char *chaine, const char *joker, LLint *size,
|
||||
int *size_flag);
|
||||
/* strjoker() reporting the work-budget steps it spent and the cap; test-only,
|
||||
lets a self-test assert the budget bounds a hostile pattern's work. */
|
||||
const char *strjoker_steps(const char *chaine, const char *joker,
|
||||
size_t *nsteps_out, size_t *maxsteps_out);
|
||||
const char *strjokerfind(const char *chaine, const char *joker);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -744,33 +744,29 @@ static int st_filterdual(httrackp *opt, int argc, char **argv) {
|
||||
process (OSS-Fuzz 5060751291908096 / 5745936014573568). */
|
||||
static int st_filterbounds(httrackp *opt, int argc, char **argv) {
|
||||
const size_t big = 100000; /* well past the length cap */
|
||||
const size_t stars = 1023; /* pattern len 2047, under the length cap */
|
||||
const size_t subjlen = 2048;
|
||||
const size_t stars = 900; /* star-heavy pattern, under the cap */
|
||||
char *subj = malloct(big + 1);
|
||||
char *pat = malloct(2 * stars + 2);
|
||||
size_t steps = 0, maxsteps = 0, i;
|
||||
size_t i;
|
||||
|
||||
(void) opt;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
memset(subj, 'a', big);
|
||||
subj[big] = '\0';
|
||||
/* '*' matches anything, but an over-length subject trips the length cap */
|
||||
/* '*' matches anything, but an over-length subject is refused by the cap */
|
||||
assertf(strjoker(subj, "*", NULL, NULL) == NULL);
|
||||
assertf(strjokerfind(subj, "*") == NULL);
|
||||
/* Star-heavy dead-end at the length cap: unbounded it runs ~1.26e9 memo-steps
|
||||
(~6s). */
|
||||
/* within-cap star-heavy dead-end: the step budget keeps it bounded (a hang
|
||||
would time the test out) */
|
||||
for (i = 0; i < stars; i++) {
|
||||
pat[2 * i] = '*';
|
||||
pat[2 * i + 1] = 'a';
|
||||
}
|
||||
pat[2 * stars] = 'b'; /* never matches an all-'a' subject */
|
||||
pat[2 * stars + 1] = '\0';
|
||||
subj[subjlen] = '\0';
|
||||
/* Budget must fire and hold: steps > cap (deleting the budget zeroes the
|
||||
counter that is the enforcement), steps < 10*cap (unbudgeted ~1.26e9). */
|
||||
assertf(strjoker_steps(subj, pat, &steps, &maxsteps) == NULL);
|
||||
assertf(steps > maxsteps && steps < 10 * maxsteps);
|
||||
subj[stars] = '\0';
|
||||
assertf(strjoker(subj, pat, NULL, NULL) == NULL);
|
||||
assertf(strjokerfind(subj, pat) == NULL);
|
||||
freet(pat);
|
||||
freet(subj);
|
||||
|
||||
Reference in New Issue
Block a user