debian-567480_handle-eol-at-eof.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. Description: Catch missing EOL at EOF
  2. Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
  3. Forwarded: http://sourceforge.net/mailarchive/forum.php?thread_name=1360193802%40msgid.manchmal.in-ulm.de&forum_name=poptop-server
  4. Bug: http://sourceforge.net/p/poptop/bugs/35/
  5. Bug-Debian: http://bugs.debian.org/567480
  6. --- a/configfile.c
  7. +++ b/configfile.c
  8. @@ -57,14 +57,18 @@
  9. while ((fgets(buffer, MAX_CONFIG_STRING_SIZE - 1, in)) != NULL) {
  10. /* ignore long lines */
  11. if (buffer[(len = strlen(buffer)) - 1] != '\n') {
  12. - syslog(LOG_ERR, "Long config file line ignored.");
  13. - do
  14. - fgets(buffer, MAX_CONFIG_STRING_SIZE - 1, in);
  15. - while (buffer[strlen(buffer) - 1] != '\n');
  16. - continue;
  17. + if (len >= MAX_CONFIG_STRING_SIZE - 2) {
  18. + syslog(LOG_ERR, "Long config file line ignored.");
  19. + char *p;
  20. + do
  21. + p = fgets(buffer, MAX_CONFIG_STRING_SIZE - 1, in);
  22. + while (p && buffer[strlen(buffer) - 1] != '\n');
  23. + continue;
  24. + }
  25. + } else {
  26. + len--; /* For the NL at the end */
  27. }
  28. - len--; /* For the NL at the end */
  29. while (--len >= 0)
  30. if (buffer[len] != ' ' && buffer[len] != '\t')
  31. break;