From 4e564b59c7c565387c4907017dfacce2ef761f8a Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Fri, 1 Jul 2011 20:49:06 +0200 Subject: [PATCH] Properly parse search size expressions as off_t, not int. --- daemon/fnet-dc.c | 18 +++++++++--------- daemon/search.c | 8 ++++---- daemon/search.h | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/daemon/fnet-dc.c b/daemon/fnet-dc.c index a79a681..fd7a79d 100644 --- a/daemon/fnet-dc.c +++ b/daemon/fnet-dc.c @@ -2429,9 +2429,9 @@ static int hubsendchat(struct fnetnode *fn, int public, wchar_t *to, wchar_t *st return(0); } -static void findsizelimit(struct sexpr *sexpr, int *min, int *max) +static void findsizelimit(struct sexpr *sexpr, off_t *min, off_t *max) { - int minl, maxl, minr, maxr, retmin, retmax; + off_t minl, maxl, minr, maxr, retmin, retmax; switch(sexpr->op) { @@ -2475,14 +2475,14 @@ static void findsizelimit(struct sexpr *sexpr, int *min, int *max) } case SOP_SIZELT: retmin = 0; - retmax = sexpr->d.n - 1; + retmax = sexpr->d.sz - 1; break; case SOP_SIZEEQ: - retmin = sexpr->d.n; - retmax = sexpr->d.n; + retmin = sexpr->d.sz; + retmax = sexpr->d.sz; break; case SOP_SIZEGT: - retmin = sexpr->d.n + 1; + retmin = sexpr->d.sz + 1; retmax = -1; break; default: @@ -2533,7 +2533,7 @@ static int hubsearch(struct fnetnode *fn, struct search *srch, struct srchfnnlis size_t sstrsize, sstrdata; struct sockaddr *name; socklen_t namelen; - int minsize, maxsize; + off_t minsize, maxsize; struct hash *hash; hub = fn->data; @@ -2566,10 +2566,10 @@ static int hubsearch(struct fnetnode *fn, struct search *srch, struct srchfnnlis if(minsize != 0) { sizebuf2(sstr, sstrdata + 32, 1); - sstrdata += snprintf(sstr + sstrdata, sstrsize - sstrdata, "T?F?%i?1?", minsize); + sstrdata += snprintf(sstr + sstrdata, sstrsize - sstrdata, "T?F?%ji?1?", (intmax_t)minsize); } else if(maxsize != -1) { sizebuf2(sstr, sstrdata + 32, 1); - sstrdata += snprintf(sstr + sstrdata, sstrsize - sstrdata, "T?T?%i?1?", maxsize); + sstrdata += snprintf(sstr + sstrdata, sstrsize - sstrdata, "T?T?%ji?1?", (intmax_t)maxsize); } else { bufcat(sstr, "F?F?0?1?", 8); } diff --git a/daemon/search.c b/daemon/search.c index b70e7ae..633e07e 100644 --- a/daemon/search.c +++ b/daemon/search.c @@ -664,7 +664,7 @@ struct sexpr *parsesexpr(int argc, wchar_t **argv) sexpr->op = SOP_SIZEEQ; else sexpr->op = SOP_SIZEGT; - sexpr->d.n = wcstol(tok2->d.str + 2, NULL, 0); + sexpr->d.sz = wcstoll(tok2->d.str + 2, NULL, 0); sexpr->cost = 0; getsexpr(tok->d.se = sexpr); freetok(tok2); @@ -1110,11 +1110,11 @@ static int srisvalid(struct srchres *sr, struct sexpr *sexpr) p = fnfilebasename(sr->filename); return(wcsexists(p, sexpr->d.s)); case SOP_SIZELT: - return(sr->size < sexpr->d.n); + return(sr->size < sexpr->d.sz); case SOP_SIZEEQ: - return(sr->size == sexpr->d.n); + return(sr->size == sexpr->d.sz); case SOP_SIZEGT: - return(sr->size > sexpr->d.n); + return(sr->size > sexpr->d.sz); case SOP_HASHIS: if(sr->hash == NULL) return(0); diff --git a/daemon/search.h b/daemon/search.h index 230436c..d1b8b78 100644 --- a/daemon/search.h +++ b/daemon/search.h @@ -64,7 +64,7 @@ struct sexpr int inited; } re; wchar_t *s; - int n; + off_t sz; struct hash *hash; } d; }; -- 2.11.0