patch-wmphoto_wmphoto_c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. $OpenBSD: patch-wmphoto_wmphoto_c,v 1.1.1.1 2001/01/16 22:44:43 naddy Exp $
  2. --- wmphoto/wmphoto.c.orig Sun Oct 3 07:11:37 1999
  3. +++ wmphoto/wmphoto.c Tue Jan 16 18:05:55 2001
  4. @@ -34,7 +34,6 @@ char current[1024];
  5. char home[1024];
  6. -
  7. int main(int argc, char **argv)
  8. {
  9. init_stuff(argc, argv);
  10. @@ -49,7 +48,7 @@ int main(int argc, char **argv)
  11. void init_stuff(int argc, char **argv)
  12. {
  13. /* get the user's home */
  14. - sprintf(home,"%s/.wmphoto",getenv("HOME"));
  15. + snprintf(home,sizeof(home),"%s/.wmphoto",getenv("HOME"));
  16. if (argc == 2)
  17. { show_usage(); }
  18. @@ -194,7 +193,7 @@ void get_next_photo(char *current)
  19. -int myselect(const struct dirent *d)
  20. +int myselect(struct dirent *d)
  21. { char *name = d->d_name;
  22. static int lenght;
  23. static char *defExt = ".xpm.gz";
  24. @@ -223,7 +222,7 @@ void load_photo(char *name)
  25. mylenght = strlen(defExt);
  26. - sprintf(current, "%s/%s", home, name);
  27. + snprintf(current, sizeof(current), "%s/%s", home, name);
  28. lenght = strlen(current);
  29. current[lenght - mylenght] = 0;
  30. @@ -252,7 +251,7 @@ void load_photo(char *name)
  31. status = XpmReadFileToPixmap(display, wmgen.pixmap, current, &mypixmap,
  32. 0, &xpmAttributes);
  33. - strcpy(current, name);
  34. + strlcpy(current, name, sizeof(current));
  35. if (status != XpmSuccess)
  36. { fprintf(stderr, "wmphoto (XpmError): %s\n",
  37. XpmGetErrorString(status));
  38. @@ -298,7 +297,8 @@ void add_photo(char *filename)
  39. }
  40. printf("good.\n\n");
  41. }
  42. - closedir(mydir);
  43. + else
  44. + closedir(mydir);
  45. @@ -315,7 +315,7 @@ void add_photo(char *filename)
  46. printf("Command to run for button2? (ex: xterm -e talk amartoq@cec.uchile.cl)\n");
  47. fgets(command2, 1024, stdin);
  48. - sprintf(current, "%s/%s", home, profile);
  49. + snprintf(current, sizeof(current), "%s/%s", home, profile);
  50. printf("Creating %s... ", current);
  51. myfile = fopen(current, "w");
  52. @@ -329,7 +329,7 @@ void add_photo(char *filename)
  53. fclose(myfile);
  54. printf("good.\nExecuting convert, this may take a while...\n");
  55. - sprintf(current, "convert -colors 255 -dither -geometry 48x52! %s xpm:%s/%s.xpm.gz", filename, home, profile);
  56. + snprintf(current, sizeof(current), "convert -colors 255 -dither -geometry 48x52! %s xpm:%s/%s.xpm.gz", filename, home, profile);
  57. printf("%s ", current);
  58. fflush(stdout);
  59. @@ -345,7 +345,7 @@ void show_usage()
  60. {
  61. printf("[wmphoto %s] Copyright(C) 1999, by Aldrin Martoq A. (amartoq@cec.uchile.cl)\n", WMPHOTO_VERSION);
  62. - printf("ussage:\nwmphoto\n\t Starts the wmphoto as dock app.\n\nwmphoto add <an_image_file>\n\t Add the photo <an_image_file> to your ~/.wmphoto directory interactivaly\n\t(Imagemagick's `convert` program needed).\n\n");
  63. + printf("usage:\nwmphoto\n\t Starts the wmphoto as dock app.\n\nwmphoto add <an_image_file>\n\t Add the photo <an_image_file> to your ~/.wmphoto directory interactivaly\n\t(Imagemagick's `convert` program needed).\n\n");
  64. exit(0);
  65. }