aboutsummaryrefslogtreecommitdiff
path: root/src/IO/dpi.c
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-28 16:08:04 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-28 16:08:04 +0100
commit2ad31b7aab4b9dda30cf1a914d6191eab7cebfcc (patch)
tree94619e33fe5cee0fc60c807edea08963eaad5bdd /src/IO/dpi.c
parent576066bd1b653908b06db1daab42d041376da678 (diff)
check fgets() and write() results
Diffstat (limited to 'src/IO/dpi.c')
-rw-r--r--src/IO/dpi.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/IO/dpi.c b/src/IO/dpi.c
index 01d3a5b5..ef77a88a 100644
--- a/src/IO/dpi.c
+++ b/src/IO/dpi.c
@@ -371,7 +371,7 @@ static char *Dpi_get_dpid_uds_dir(void)
{
FILE *in;
char *saved_name_filename; /* :) */
- char dpid_uds_dir[256], *p = NULL;
+ char buf[256], *dpid_uds_dir, *p = NULL, *nl;
saved_name_filename =
dStrconcat(dGethomedir(), "/.dillo/dpi_socket_dir", NULL);
@@ -379,14 +379,16 @@ static char *Dpi_get_dpid_uds_dir(void)
dFree(saved_name_filename);
if (in != NULL) {
- fgets(dpid_uds_dir, 256, in);
+ dpid_uds_dir = fgets(buf, sizeof(buf), in);
fclose(in);
- if ((p = strchr(dpid_uds_dir, '\n'))) {
- *p = 0;
- }
- if (access(dpid_uds_dir, F_OK) == 0) {
- p = dStrdup(dpid_uds_dir);
- _MSG("Dpi_get_dpid_uds_dir:: %s\n", p);
+ if (dpid_uds_dir) {
+ if ((nl = strchr(dpid_uds_dir, '\n'))) {
+ *nl = 0;
+ }
+ if (access(dpid_uds_dir, F_OK) == 0) {
+ p = dStrdup(dpid_uds_dir);
+ _MSG("Dpi_get_dpid_uds_dir:: %s\n", p);
+ }
}
}
@@ -730,7 +732,9 @@ void a_Dpi_bye_dpid()
MSG("%s\n", sa.sun_path);
}
DpiBye_cmd = a_Dpip_build_cmd("cmd=%s", "DpiBye");
- (void) write(new_socket, DpiBye_cmd, strlen(DpiBye_cmd));
+ if (write(new_socket, DpiBye_cmd, strlen(DpiBye_cmd)) !=
+ (ssize_t) strlen(DpiBye_cmd))
+ MSG_WARN("Failed to send DpiBye\n");
dFree(DpiBye_cmd);
Dpi_close_fd(new_socket);
}