Dolda2000 GitWeb
/
doldaconnect.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6d7174d
)
Be more strict on incoming searches.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 26 Mar 2014 01:07:59 +0000
(
02:07
+0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 26 Mar 2014 01:07:59 +0000
(
02:07
+0100)
daemon/fnet-dc.c
patch
|
blob
|
blame
|
history
diff --git
a/daemon/fnet-dc.c
b/daemon/fnet-dc.c
index
30b0a24
..
85ba9a0
100644
(file)
--- a/
daemon/fnet-dc.c
+++ b/
daemon/fnet-dc.c
@@
-1125,7
+1125,7
@@
static void cmd_search(struct socket *sk, struct fnetnode *fn, char *cmd, char *
int minsize, maxsize;
int dotth;
size_t buflen;
int minsize, maxsize;
int dotth;
size_t buflen;
- int termnum, satisfied,
skipcheck
;
+ int termnum, satisfied,
matches, skipcheck, proper
;
int level, tersat[32];
wchar_t *terms[32], *lname;
char hashtth[24];
int level, tersat[32];
wchar_t *terms[32], *lname;
char hashtth[24];
@@
-1194,6
+1194,7
@@
static void cmd_search(struct socket *sk, struct fnetnode *fn, char *cmd, char *
termnum = 0;
p2 = p;
done = 0;
termnum = 0;
p2 = p;
done = 0;
+ proper = 0;
while(!done)
{
if((*p2 == 0) || (*p2 == '$'))
while(!done)
{
if((*p2 == 0) || (*p2 == '$'))
@@
-1217,6
+1218,8
@@
static void cmd_search(struct socket *sk, struct fnetnode *fn, char *cmd, char *
} else {
if((terms[termnum] = icmbstowcs(p, hub->charset)) != NULL) {
wcslower(terms[termnum]);
} else {
if((terms[termnum] = icmbstowcs(p, hub->charset)) != NULL) {
wcslower(terms[termnum]);
+ if(wcslen(terms[termnum]) > 1)
+ proper = 1;
termnum++;
}
}
termnum++;
}
}
@@
-1227,12
+1230,15
@@
static void cmd_search(struct socket *sk, struct fnetnode *fn, char *cmd, char *
}
p2++;
}
}
p2++;
}
+ if(!proper)
+ goto out;
node = shareroot->child;
level = 0;
for(i = 0; i < termnum; i++)
tersat[i] = -1;
satisfied = 0;
node = shareroot->child;
level = 0;
for(i = 0; i < termnum; i++)
tersat[i] = -1;
satisfied = 0;
+ matches = 0;
while(1)
{
skipcheck = 0;
while(1)
{
skipcheck = 0;
@@
-1279,6
+1285,8
@@
static void cmd_search(struct socket *sk, struct fnetnode *fn, char *cmd, char *
qstrf(dsk, "%s%s\005%ji%s%s%s", prefix, buf, (intmax_t)node->size, infix, hub->nativename, postfix);
}
free(buf);
qstrf(dsk, "%s%s\005%ji%s%s%s", prefix, buf, (intmax_t)node->size, infix, hub->nativename, postfix);
}
free(buf);
+ if(++matches >= 20)
+ break;
}
}
if((!skipcheck && (satisfied == termnum)) || (node->child == NULL))
}
}
if((!skipcheck && (satisfied == termnum)) || (node->child == NULL))