patch-abbrev_c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. $OpenBSD: patch-abbrev_c,v 1.2 2017/05/12 20:27:25 naddy Exp $
  2. Index: abbrev.c
  3. --- abbrev.c.orig
  4. +++ abbrev.c
  5. @@ -16,11 +16,15 @@
  6. #endif
  7. #endif
  8. +#include <curses.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. +#include <unistd.h>
  12. #include <ctype.h>
  13. #include "sc.h"
  14. +int are_abbrevs();
  15. +
  16. static struct abbrev *abbr_base;
  17. void
  18. @@ -43,10 +47,10 @@ add_abbr(char *string)
  19. struct abbrev *a;
  20. struct abbrev *nexta;
  21. - (void) strcpy(px, "| ");
  22. + (void) strlcpy(px, "| ", sizeof px);
  23. if (!(pager = getenv("PAGER")))
  24. pager = DFLT_PAGER;
  25. - (void) strcat(px, pager);
  26. + (void) strlcat(px, pager, sizeof px);
  27. f = openfile(px, &pid, NULL);
  28. if (!f) {
  29. error("Can't open pipe to %s", pager);
  30. @@ -87,7 +91,7 @@ add_abbr(char *string)
  31. }
  32. }
  33. - if (expansion == NULL)
  34. + if (expansion == NULL) {
  35. if ((a = find_abbr(string, strlen(string), &prev))) {
  36. error("abbrev \"%s %s\"", a->abbr, a->exp);
  37. return;
  38. @@ -95,6 +99,7 @@ add_abbr(char *string)
  39. error("abreviation \"%s\" doesn't exist", string);
  40. return;
  41. }
  42. + }
  43. if (find_abbr(string, strlen(string), &prev))
  44. del_abbr(string);