OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.1 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../dog/check-ctime.patch
  5. # Copyright (C) 2007 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. diff --exclude='*~' --exclude='.*' -I '$Id:' -urN dog-1.7.orig/dog.c dog-1.7/dog.c
  17. This patch comes from Gentoo, author is the Gentoo maintainer of dog.
  18. --- ./dog.c 2005-05-13 08:01:37.000000000 -0400
  19. +++ ./dog.c 2005-05-13 08:30:38.000000000 -0400
  20. @@ -36,6 +36,7 @@
  21. #include <string.h>
  22. #include "getopt.h"
  23. #include <limits.h>
  24. +#include <time.h>
  25. #include <netdb.h>
  26. // this is fun
  27. @@ -1321,26 +1322,35 @@
  28. InetSockAddr sa;
  29. int newsock;
  30. uint32 ipAddr;
  31. - int k;
  32. + socklen_t k;
  33. time_t curr_time;
  34. char curr_date[64];
  35. k = sizeof(sa);
  36. while ((newsock=accept(sock,(struct sockaddr*)&sa,&k)) != -1) {
  37. if (!no_bind_header) {
  38. + char *result = NULL;
  39. ipAddr = ntohl(sa.addr);
  40. time(&curr_time);
  41. - strcpy(curr_date,ctime(&curr_time));
  42. + if (!(result = ctime(&curr_time))) {
  43. + perror("ctime");
  44. + goto done;
  45. + }
  46. + strncpy(curr_date, result, sizeof(curr_date) - 1);
  47. while (!isalnum(curr_date[strlen(curr_date)-1])) {
  48. curr_date[strlen(curr_date)-1] = 0;
  49. }
  50. printf("# %s from %d.%d.%d.%d:%d\n",curr_date,(int)ipAddr>>24,(int)(ipAddr>>16)&0xff,(int)(ipAddr>>8)&0xff,(int)ipAddr&0xff,ntohs(sa.port));
  51. }
  52. - straight_dump = newsock;
  53. - DumpThings(argc,argv,hang_up_bind ? -1 : newsock);
  54. - if (hang_up_bind) {
  55. +
  56. + goto done;
  57. +
  58. + done:
  59. + straight_dump = newsock;
  60. + DumpThings(argc,argv,hang_up_bind ? -1 : newsock);
  61. + if (hang_up_bind) {
  62. close(newsock);
  63. - }
  64. + }
  65. }
  66. }