summaryrefslogtreecommitdiffstats
path: root/friendfinder
diff options
context:
space:
mode:
authorPatrick Hornecker2010-01-29 12:00:44 +0100
committerPatrick Hornecker2010-01-29 12:00:44 +0100
commitc8e4f9198d2055515a4678ae1f1136979e8cb431 (patch)
tree4bb23ce3f096887805873d90584776310163f188 /friendfinder
parenttex source (diff)
downloadfriendfinder-c8e4f9198d2055515a4678ae1f1136979e8cb431.tar.gz
friendfinder-c8e4f9198d2055515a4678ae1f1136979e8cb431.tar.xz
friendfinder-c8e4f9198d2055515a4678ae1f1136979e8cb431.zip
bugs and memory fixes
Diffstat (limited to 'friendfinder')
-rw-r--r--friendfinder/msg_sender.c16
-rw-r--r--friendfinder/sender.c19
2 files changed, 28 insertions, 7 deletions
diff --git a/friendfinder/msg_sender.c b/friendfinder/msg_sender.c
index 40eb75b..33e54cd 100644
--- a/friendfinder/msg_sender.c
+++ b/friendfinder/msg_sender.c
@@ -113,17 +113,19 @@ struct msg_part* prepare_msg(char *msg)
i++;
}
}
+
for (int i = 0; i <= msg_p->part_count; i++)
{
printf("%i %s \n", i, msg_p->msg_parts[i]);
}
+
+ free(message);
+
return msg_p;
}
void repair_msg(char* inc_msg, char *msg)
{
- int len = strlen(inc_msg);
- printf("repair_msg len: %i \n", len);
printf("repair_msg: %s \n", msg);
if (strcmp(inc_msg, "//c//") != 0)
@@ -141,6 +143,7 @@ void set_txt_msg(char *msg)
struct msg_part *msg_p = (struct msg_part*) malloc(sizeof(struct msg_part));
msg_p = prepare_msg(msg);
send_message(session, msg_p);
+ // free(msg_p);
}
else printf("MSG_SENDER: session not initialized \n");
}
@@ -162,11 +165,17 @@ void send_message(irc_session_t *session, struct msg_part *msg_p)
}
char* eof = "//c//";
- char *crypted_eof = (char*) malloc(sizeof(char));
+ char *crypted_eof = (char*) malloc(sizeof(char) * sizeof(eof));
BF_ecb_encrypt(eof, crypted_eof, &key, BF_ENCRYPT);
irc_cmd_msg(session, "#msg", crypted_eof);
+
free(crypted_eof);
+ for (int i = 0; i < msg_p->part_count; i++)
+ {
+ free(msg_p->msg_parts[i]);
+ }
+ free(msg_p->msg_parts);
free(msg_p);
}
@@ -199,6 +208,7 @@ void on_channel(irc_session_t * session, const char * event, const char * origin
else
{
BF_ecb_encrypt(params[1], inc_msg, &key, BF_DECRYPT);
+ printf("%s \n", inc_msg);
repair_msg(inc_msg, msg);
}
}
diff --git a/friendfinder/sender.c b/friendfinder/sender.c
index 3f9c683..321d5e9 100644
--- a/friendfinder/sender.c
+++ b/friendfinder/sender.c
@@ -63,8 +63,10 @@ void set_sender_position(double lat, double lon)
void send_position(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
- unsigned char crypted_lat[64];
- unsigned char crypted_lon[64];
+// unsigned char crypted_lat[64];
+ unsigned char *crypted_lat = (char*) malloc(sizeof(char) * 9);
+// unsigned char crypted_lon[64];
+ unsigned char *crypted_lon = (char*) malloc(sizeof(char) * 9);
if (first_send == 0)
{
@@ -77,12 +79,16 @@ void send_position(irc_session_t * session, const char * event, const char * ori
irc_cmd_msg(session, "#test", "connected");
first_send = 1;
+
+ //free(key);
}
- unsigned char lat_char[16];
+// unsigned char lat_char[16];
+ unsigned char *lat_char = (char*) malloc(sizeof(char) * 9);
sprintf(lat_char, "%f", own_lat);
- unsigned char lon_char[16];
+// unsigned char lon_char[16];
+ unsigned char *lon_char = (char*) malloc(sizeof(char) * 9);
sprintf(lon_char, "%f", own_lon);
BF_ecb_encrypt(lat_char, crypted_lat, &key, BF_ENCRYPT);
@@ -117,6 +123,11 @@ void send_position(irc_session_t * session, const char * event, const char * ori
resend = 0;
ack_count = 0;
}
+
+ free(lat_char);
+ free(lon_char);
+ free(crypted_lat);
+ free(crypted_lon);
}
void get_aknowledge(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)