diff options
Diffstat (limited to 'dpi')
-rw-r--r-- | dpi/bookmarks.c | 18 | ||||
-rw-r--r-- | dpi/cookies.c | 39 | ||||
-rw-r--r-- | dpi/datauri.c | 7 | ||||
-rw-r--r-- | dpi/ftp.c | 8 |
4 files changed, 58 insertions, 14 deletions
diff --git a/dpi/bookmarks.c b/dpi/bookmarks.c index dca12248..da4f422a 100644 --- a/dpi/bookmarks.c +++ b/dpi/bookmarks.c @@ -687,15 +687,29 @@ static void Bms_check_import(void) "grep -i \"href\" %s | " "sed -e 's/<li><A HREF=\"/s0 /' -e 's/\">/ /' -e 's/<.*$//' >> %s"; Dstr *dstr = dStr_new(""); + int rc; if (access(BmFile, F_OK) != 0) { OldBmFile = dStrconcat(dGethomedir(), "/.dillo/bookmarks.html", NULL); if (access(OldBmFile, F_OK) == 0) { dStr_sprintf(dstr, cmd1, BmFile); - system(dstr->str); + rc = system(dstr->str); + if (rc == 127) { + MSG("Bookmarks: /bin/sh could not be executed\n"); + } else if (rc == -1) { + MSG("Bookmarks: process creation failure: %s\n", + dStrerror(errno)); + } dStr_sprintf(dstr, cmd2, OldBmFile, BmFile); - system(dstr->str); + rc = system(dstr->str); + if (rc == 127) { + MSG("Bookmarks: /bin/sh could not be executed\n"); + } else if (rc == -1) { + MSG("Bookmarks: process creation failure: %s\n", + dStrerror(errno)); + } + dStr_free(dstr, TRUE); dFree(OldBmFile); } diff --git a/dpi/cookies.c b/dpi/cookies.c index 44b1a9be..0bb6ee09 100644 --- a/dpi/cookies.c +++ b/dpi/cookies.c @@ -178,14 +178,19 @@ static FILE *Cookies_fopen(const char *filename, const char *mode, char *init_str) { FILE *F_in; - int fd; + int fd, rc; if ((F_in = fopen(filename, mode)) == NULL) { /* Create the file */ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (fd != -1) { - if (init_str) - write(fd, init_str, strlen(init_str)); + if (init_str) { + rc = write(fd, init_str, strlen(init_str)); + if (rc == -1) { + MSG("Cookies: Could not write initial string to file %s: %s\n", + filename, dStrerror(errno)); + } + } close(fd); MSG("Created file: %s\n", filename); @@ -222,7 +227,7 @@ static void Cookies_free_cookie(CookieData_t *cookie) static void Cookies_init() { CookieData_t *cookie; - char *filename; + char *filename, *rc = NULL; char line[LINE_MAXLEN]; #ifndef HAVE_LOCKF struct flock lck; @@ -273,7 +278,12 @@ static void Cookies_init() /* Get all lines in the file */ while (!feof(file_stream)) { line[0] = '\0'; - fgets(line, LINE_MAXLEN, file_stream); + rc = fgets(line, LINE_MAXLEN, file_stream); + if (!rc && ferror(file_stream)) { + MSG("Cookies1: Error while reading rule from cookiesrc: %s\n", + dStrerror(errno)); + break; /* bail out */ + } /* Remove leading and trailing whitespaces */ dStrstrip(line); @@ -338,7 +348,12 @@ static void Cookies_init() /* Get all lines in the file */ while (!feof(old_cookies_file_stream)) { line[0] = '\0'; - fgets(line, LINE_MAXLEN, old_cookies_file_stream); + rc = fgets(line, LINE_MAXLEN, old_cookies_file_stream); + if (!rc && ferror(old_cookies_file_stream)) { + MSG("Cookies2: Error while reading rule from cookiesrc: %s\n", + dStrerror(errno)); + break; /* bail out */ + } /* Remove leading and trailing whitespaces */ dStrstrip(line); @@ -425,7 +440,8 @@ static void Cookies_save_and_free() rewind(file_stream); fd = fileno(file_stream); - ftruncate(fd, 0); + if (ftruncate(fd, 0) == -1) + MSG("Cookies: Truncate file stream failed: %s\n", dStrerror(errno)); fprintf(file_stream, "%s", cookies_txt_header_str); /* Iterate cookies per domain, saving and freeing */ @@ -1213,7 +1229,7 @@ static int Cookie_control_init(void) { CookieControl cc; FILE *stream; - char *filename; + char *filename, *rc; char line[LINE_MAXLEN]; char domain[LINE_MAXLEN]; char rule[LINE_MAXLEN]; @@ -1231,7 +1247,12 @@ static int Cookie_control_init(void) /* Get all lines in the file */ while (!feof(stream)) { line[0] = '\0'; - fgets(line, LINE_MAXLEN, stream); + rc = fgets(line, LINE_MAXLEN, stream); + if (!rc && ferror(stream)) { + MSG("Cookies3: Error while reading rule from cookiesrc: %s\n", + dStrerror(errno)); + break; /* bail out */ + } /* Remove leading and trailing whitespaces */ dStrstrip(line); diff --git a/dpi/datauri.c b/dpi/datauri.c index 9d8fbcb7..dd0dbf7f 100644 --- a/dpi/datauri.c +++ b/dpi/datauri.c @@ -275,12 +275,17 @@ int main(void) { char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *mime_type; unsigned char *data; + int rc; size_t data_size = 0; /* Initialize the SockHandler */ sh = sock_handler_new(STDIN_FILENO, STDOUT_FILENO, 8*1024); - chdir("/tmp"); + rc = chdir("/tmp"); + if (rc == -1) { + MSG("paths: error changing directory to /tmp: %s\n", + dStrerror(errno)); + } /* Read the dpi command from STDIN */ dpip_tag = sock_handler_read(sh); @@ -266,7 +266,7 @@ static int try_ftp_transfer(char *url) int main(int argc, char **argv) { char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *url2 = NULL; - int nb; + int nb, rc; char *p, *d_cmd; /* Debugging with a command line argument */ @@ -277,7 +277,11 @@ int main(int argc, char **argv) sh = sock_handler_new(STDIN_FILENO, STDOUT_FILENO, 8*1024); /* wget may need to write a temporary file... */ - chdir("/tmp"); + rc = chdir("/tmp"); + if (rc == -1) { + MSG("paths: error changing directory to /tmp: %s\n", + dStrerror(errno)); + } /* Read the dpi command from STDIN */ if (!dpip_tag) |