Skip to content

Commit

Permalink
Add more error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann committed Jun 25, 2024
1 parent 0ade9d8 commit 796e889
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/mod/share.mod/share.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <errno.h>
#include "src/mod/module.h"
#include <resolv.h>

#include <netinet/in.h>
#include <arpa/inet.h>
Expand Down Expand Up @@ -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 <len>
*/
#include <resolv.h>
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);
Expand All @@ -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,
Expand Down

0 comments on commit 796e889

Please sign in to comment.