From 244dd304483a52b480e6d388c1f9accbfb79acb4 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Fri, 23 Dec 2005 15:15:55 +0000 Subject: [PATCH] Fixed a crash when files.bbs had empty lines --- ChangeLog | 3 +++ mbfido/mbfimport.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 43fd2b52..165a19de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ $Id$ v0.83.6 17-Dec-2005 + mbfile: + Fixed a crash when files.bbs had empty lines. + mbtask: Better messages during servers connections reset. diff --git a/mbfido/mbfimport.c b/mbfido/mbfimport.c index 87d95688..adaacdc9 100644 --- a/mbfido/mbfimport.c +++ b/mbfido/mbfimport.c @@ -115,6 +115,24 @@ void ImportFiles(int Area) while (fgets(String, 4095, fbbs) != NULL) { + /* + * Strip cr and lf characters + */ + for (i = 0; i < strlen(String); i++) { + if (*(String + i) == '\0') + break; + if (*(String + i) == '\n') + *(String + i) = '\0'; + if (*(String + i) == '\r') + *(String + i) = '\0'; + } + + /* + * Stop on an empty line + */ + if (strlen(String) == 0) + break; + if ((String[0] != ' ') && (String[0] != '\t')) { /* * New file entry, check if there has been a file that is not yet saved.