瀏覽代碼

* Some update fixes

svn: 1100
Bryan Drewery 22 年之前
父節點
當前提交
6f7704a922
共有 2 個文件被更改,包括 14 次插入7 次删除
  1. 6 1
      src/mod/transfer.mod/transfer.c
  2. 8 6
      src/mod/update.mod/update.c

+ 6 - 1
src/mod/transfer.mod/transfer.c

@@ -28,6 +28,7 @@
 #include <sys/stat.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <errno.h>
 
 extern int		bupdating;
 
@@ -1101,7 +1102,11 @@ static int raw_dcc_resend_send(char *filename, char *nick, char *from, char *dir
  
   sdprintf("raw_dcc_resend_send()");
   zz = (-1);
-  dccfile = fopen(filename,"rb");
+  dccfile = fopen(filename, "rb");
+  if (!dccfile) {
+    putlog(LOG_MISC, "*", "Failed to open %s: %s", filename, strerror(errno));
+    return DCCSEND_FEMPTY;
+  }
   fseek(dccfile, 0, SEEK_END);
   dccfilesize = ftell(dccfile);
   fclose(dccfile);

+ 8 - 6
src/mod/update.mod/update.c

@@ -285,7 +285,7 @@ static void start_sending_binary(int idx)
 {
   /* module_entry *me; */
 #ifdef HUB
-  char update_file[DIRMAX] = "", tmpFile[1024] = "", *sysname = NULL;
+  char update_file[51] = "", update_fpath[DIRMAX] = "", tmpFile[1024] = "", *sysname = NULL;
   int i = 1;
 
   dcc[idx].status &= ~(STAT_OFFEREDU | STAT_SENDINGU);
@@ -305,11 +305,13 @@ static void start_sending_binary(int idx)
     return;
   }
 
-  sprintf(update_file, "%s%s.%s-%s", dirname(binname), (bot_hublevel(dcc[idx].user) == 999) ? "leaf" : "hub", 
-                                     sysname, egg_version);
+  egg_snprintf(update_file, sizeof update_file, "%s.%s-%s", 
+              (bot_hublevel(dcc[idx].user) == 999) ? "leaf" : "hub", sysname, egg_version);
 
-  if (!can_stat(update_file)) {
-    putlog(LOG_MISC, "*", "Need to update \002%s\002 with %s, but it cannot be accessed", dcc[idx].nick, update_file);
+  egg_snprintf(update_fpath, sizeof update_fpath, "%s/%s", dirname(binname), update_file);
+
+  if (!can_stat(update_fpath)) {
+    putlog(LOG_MISC, "*", "Need to update \002%s\002 with %s, but it cannot be accessed", dcc[idx].nick, update_fpath);
     bupdating = 0;
     return;
   }
@@ -317,7 +319,7 @@ static void start_sending_binary(int idx)
   /* copy the binary to our tempdir and send that one. */
   sprintf(tmpFile, "%s.%s", tempdir, update_file);
   unlink(tmpFile);
-  copyfile(update_file, tmpFile);
+  copyfile(update_fpath, tmpFile);
 
 /* NO
   ic = 0;