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.

30 lines
1.1 KiB

  1. From b303432f2dbd6a20afa99cb462aa0a1bb740b86d Mon Sep 17 00:00:00 2001
  2. From: Michael Heimpold <mhei@heimpold.de>
  3. Date: Wed, 12 Apr 2017 23:43:18 +0200
  4. Subject: [PATCH] dataxfer.c: truncate error message to fit the column width
  5. gai_strerror() could return a string which is longer than our current
  6. column width of "Remote address". To make the output nice again,
  7. truncate the error string in this case.
  8. Signed-off-by: Michael Heimpold <mhei@heimpold.de>
  9. Signed-off-by: Corey Minyard <cminyard@mvista.com>
  10. diff --git a/dataxfer.c b/dataxfer.c
  11. index 988f4e4..75c2777 100644
  12. --- a/dataxfer.c
  13. +++ b/dataxfer.c
  14. @@ -3703,6 +3703,10 @@ showshortport(struct controller_info *cntlr, port_info_t *port)
  15. NI_NUMERICHOST | NI_NUMERICSERV);
  16. if (err) {
  17. snprintf(buffer, sizeof(buffer), "*err*,%s", gai_strerror(err));
  18. + /* gai_strerror could return an elongated string which could break
  19. + our pretty formatted output below, so truncate the string nicely */
  20. + if (strlen(buffer) > 22)
  21. + strcpy(&buffer[22 - 3], "...");
  22. count = controller_outputf(cntlr, "%s", buffer);
  23. } else {
  24. count = controller_outputf(cntlr, "%s,%s", buffer, portbuff);
  25. --
  26. 2.7.4