patch-search_c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. $OpenBSD: patch-search_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
  2. --- search.c.orig Fri Sep 28 23:34:23 2001
  3. +++ search.c Tue Oct 16 18:14:04 2001
  4. @@ -304,6 +304,9 @@ free_datum (DATUM * d)
  5. {
  6. int i;
  7. TokenRef *ref;
  8. +#if RESUME
  9. + FileList *flist;
  10. +#endif
  11. for (i = 0; i < d->numTokens; i++)
  12. {
  13. @@ -342,13 +345,31 @@ free_datum (DATUM * d)
  14. FREE (d->tokens);
  15. - /* XXX broken */
  16. #if RESUME
  17. flist = hash_lookup (MD5, d->hash);
  18. if (flist)
  19. {
  20. + DList *list;
  21. +
  22. ASSERT (validate_flist (flist));
  23. - flist->list = list_delete (flist->list, d);
  24. + for (list = flist->list; list; list = list->next)
  25. + {
  26. + if (list->data == d)
  27. + {
  28. + if (list->prev)
  29. + list->prev->next = list->next;
  30. + else
  31. + {
  32. + /* element is head of list, update the flist pointer */
  33. + flist->list = list->next;
  34. + }
  35. + if (list->next)
  36. + list->next->prev = list->prev;
  37. + FREE (list);
  38. + break;
  39. + }
  40. + }
  41. +
  42. flist->count--;
  43. /* if there are no more files in this bin, erase it */
  44. if (flist->count == 0)
  45. @@ -944,6 +965,13 @@ HANDLER (search)
  46. return;
  47. }
  48. + /* NO SOUP FOR YOU!!! */
  49. + if (con->user->level == LEVEL_LEECH)
  50. + {
  51. + send_cmd (con, MSG_SERVER_SEARCH_END, "");
  52. + return;
  53. + }
  54. +
  55. /* if Max_Searches is > 0, we only allow clients to have a certain small
  56. * number of pending search requests. Some abusive clients will tend
  57. * to issues multiple search requests at a time.
  58. @@ -1015,6 +1043,13 @@ HANDLER (remote_search)
  59. if (! option (ON_ALLOW_SHARE))
  60. {
  61. /* sharing is not allowed on this server */
  62. + send_cmd (con, MSG_SERVER_REMOTE_SEARCH_END, "%s", id);
  63. + return;
  64. + }
  65. +
  66. + if (user->level == LEVEL_LEECH)
  67. + {
  68. + /* user is not allowed to search this server */
  69. send_cmd (con, MSG_SERVER_REMOTE_SEARCH_END, "%s", id);
  70. return;
  71. }