]> andersk Git - libfaim.git/commitdiff
- Thu Mar 29 13:05:50 PST 2001
authormid <mid>
Thu, 29 Mar 2001 21:10:49 +0000 (21:10 +0000)
committermid <mid>
Thu, 29 Mar 2001 21:10:49 +0000 (21:10 +0000)
  - Less leaks.

CHANGES
src/login.c
utils/faimtest/faimtest.c

diff --git a/CHANGES b/CHANGES
index a5e69faced17b9b36730100d5ec1bd9ac4041983..3cbdd9a58c68ebc3c390061a89800f3ce73d5a7f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
 
 No release numbers
 ------------------
+ - Thu Mar 29 13:05:50 PST 2001
+  - Less leaks.
+
  - Thu Mar 29 14:45:22 CST 2001 (jbm)
   - Add module capability to the 0001/001f stuff (jbm)
 
index bb26feddbd876f9ef59405fb303b42ee4286a9aa..fef6db4fb99311ddb60631d4bde8328410700964 100644 (file)
@@ -715,32 +715,29 @@ static int memrequest(struct aim_session_t *sess, aim_module_t *mod, struct comm
 {
   rxcallback_t userfunc;
   unsigned long offset, len;
-  struct aim_tlvlist_t *tlvlist;
-  struct aim_tlv_t *tlv;
-  char *modname;
+  int i = 0;
+  struct aim_tlvlist_t *list;
+  char *modname = NULL;
 
   offset = aimutil_get32(data);
+  i += 4;
+
   len = aimutil_get32(data+4);
+  i += 4;
 
-  if(rx->commandlen > 0x12) { /* XXX right len? */
-    tlvlist = aim_readtlvchain(data+8, datalen-8);
+  list = aim_readtlvchain(data+i, datalen-i);
 
-    if((tlv = aim_gettlv(tlvlist, 0x0001, 1))) {
-      modname = malloc(tlv->length + 5);
-      memset(modname, 0, tlv->length + 5);
-      memcpy(modname, tlv->value, tlv->length);
-      strncat(modname, ".ocm", tlv->length + 5 - strlen(modname));
-    } else {
-      modname = "aim.exe";
-    }
-  }  else
-    modname = "aim.exe";
-    
-  faimdprintf(sess, 1, "data at 0x%08lx (%d bytes) of %s requested\n", offset, len, modname);
+  if (aim_gettlv(list, 0x0001, 1))
+    modname = aim_gettlv_str(list, 0x0001, 1);
+
+  faimdprintf(sess, 1, "data at 0x%08lx (%d bytes) of requested\n", offset, len, modname?modname:"aim.exe");
 
   if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     return userfunc(sess, rx, offset, len, modname);
 
+  free(modname);
+  aim_freetlvchain(&list);
+
   return 0;
 }
 
index bc6656abda29e729d329095e8c2fe69f99caa4ef..06102424c434c4d340042d9e4103462b6352c5f0 100644 (file)
@@ -797,30 +797,42 @@ int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct
   return 1;
 }
 
-static int getaimdata(unsigned char *buf, int buflen, unsigned long offset, char *modname)
+static int getaimdata(unsigned char *buf, int buflen, unsigned long offset, const char *modname)
 {
   FILE *f;
+  static const char defaultmod[] = "aim.exe";
+  char *filename = NULL;
 
-  char *filename;
-  int len;
+  if (modname) {
 
-  len = strlen(aimbinarypath)+1+strlen(modname)+1;
+    if (!(filename = malloc(strlen(aimbinarypath)+1+strlen(modname)+4+1))) {
+      dperror("memrequest: malloc");
+      return -1;
+    }
+
+    sprintf(filename, "%s/%s.ocm", aimbinarypath, modname);
+
+  } else {
+
+    if (!(filename = malloc(strlen(aimbinarypath)+1+strlen(defaultmod)+1))) {
+      dperror("memrequest: malloc");
+      return -1;
+    }
+
+    sprintf(filename, "%s/%s", aimbinarypath, defaultmod);
 
-  if(!(filename = malloc(len))) {
-    dperror("memrequest: malloc");
-    return -1;
   }
 
-  memset(filename,0, len);
-  memcpy(filename, aimbinarypath, strlen(aimbinarypath));
-  filename[strlen(filename)] = '/';
-  strncat(filename, modname, len - strlen(filename));
+  dvprintf("memrequest: loading %d bytes from 0x%08lx in \"%s\"...\n", buflen, offset, filename);
 
   if (!(f = fopen(filename, "r"))) {
     dperror("memrequest: fopen");
+    free(filename);
     return -1;
   }
 
+  free(filename);
+
   if (fseek(f, offset, SEEK_SET) == -1) {
     dperror("memrequest: fseek");
     fclose(f);
@@ -865,8 +877,6 @@ static int faimtest_memrequest(struct aim_session_t *sess, struct command_rx_str
 
   if (aimbinarypath && (getaimdata(buf, len, offset, modname) == len)) {
 
-    dvprintf("memrequest: sending %ld bytes from 0x%08lx in \"%s/%s\"...\n", len, offset, aimbinarypath, modname);
-
     aim_sendmemblock(sess, command->conn, offset, len, buf);
 
   } else {
This page took 0.092529 seconds and 5 git commands to generate.