diff --git a/src/mod/share.mod/share.c b/src/mod/share.mod/share.c index b030586c4..c4dcb0253 100644 --- a/src/mod/share.mod/share.c +++ b/src/mod/share.mod/share.c @@ -26,6 +26,7 @@ #include #include "src/mod/module.h" +#include #include #include @@ -1228,11 +1229,11 @@ static void share_userfileq(int idx, char *par) /* New user file share mechanism via multiplex over already existing bot link * ur */ -#include static void share_ufsend2(int idx, char *par) { int len; unsigned char *buf; + ssize_t i; len = strlen(par); debug2("share: share_ufsend2(): start: par = >%s< len = %i", par, len); @@ -1248,7 +1249,13 @@ static void share_ufsend2(int idx, char *par) putlog(LOG_BOTS, "*", "share: share_ufsend2(): error mkstemp(): %s", strerror(errno)); return; } - write(fd, buf, len); /* TODO: error handling */ + if ((i = write(fd, buf, len)) != len) { + if (i < 0) + putlog(LOG_MISC, "*", "Share error: sare_ufsend2(): write(): %s", strerror(errno)); + else + putlog(LOG_MISC, "*", "share error: sare_ufsend2(): write(): Wrote %ld bytes instead of %i bytes.", (long) i, len); + return; + } close(fd); dcc[idx].u.xfer->filename = template; /* The new method has got no extra dcc[] for the file transfer,