projects
/
cascardo
/
rnetclient.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
When encoding message, accept 2015.
[cascardo/rnetclient.git]
/
rnetclient.c
diff --git
a/rnetclient.c
b/rnetclient.c
index
3273a9c
..
0ba06a8
100644
(file)
--- a/
rnetclient.c
+++ b/
rnetclient.c
@@
-18,6
+18,7
@@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@@
-312,8
+313,8
@@
static int rnet_send(gnutls_session_t session, char *buffer, size_t len, int hea
static int rnet_recv(gnutls_session_t session, struct rnet_message **message)
{
static int rnet_recv(gnutls_session_t session, struct rnet_message **message)
{
- char *out;
- size_t olen;
+ char *out
= NULL
;
+ size_t olen
= 0
;
char *buffer;
size_t len;
rnet_message_expand(message, 6);
char *buffer;
size_t len;
rnet_message_expand(message, 6);
@@
-378,9
+379,9
@@
static void save_rec_file(char *cpf, char *buffer, int len, const struct rnetcli
the receipt with the name "$CPF.REC". */
tmp = strstr(args->input_file, ".DEC");
if (tmp != NULL && tmp[sizeof(".DEC") - 1] == '\0') {
the receipt with the name "$CPF.REC". */
tmp = strstr(args->input_file, ".DEC");
if (tmp != NULL && tmp[sizeof(".DEC") - 1] == '\0') {
- c
onst c
har *p;
+ char *p;
/* We found the ".REC" extension. */
/* We found the ".REC" extension. */
- p = strdup(
args->input_file
);
+ p = strdup(
basename(args->input_file)
);
/* Replacing the ".DEC" by ".REC". Fortunately, we
just have to change one letter. */
tmp = strstr(p, ".DEC");
/* Replacing the ".DEC" by ".REC". Fortunately, we
just have to change one letter. */
tmp = strstr(p, ".DEC");
@@
-388,6
+389,7
@@
static void save_rec_file(char *cpf, char *buffer, int len, const struct rnetcli
fname_len = strlen(p) + strlen(path) + 2;
fname = alloca(fname_len);
snprintf(fname, fname_len, "%s/%s", path, p);
fname_len = strlen(p) + strlen(path) + 2;
fname = alloca(fname_len);
snprintf(fname, fname_len, "%s/%s", path, p);
+ free(p);
} else {
/* The declaration filename does not follow the
convention, so we will not use it as a template.
} else {
/* The declaration filename does not follow the
convention, so we will not use it as a template.
@@
-487,7
+489,12
@@
int main(int argc, char **argv)
fprintf(stderr, "error in handshake: %s\n",
gnutls_strerror(r));
fprintf(stderr, "error in handshake: %s\n",
gnutls_strerror(r));
- rnet_encode(decfile, &message);
+ r = rnet_encode(decfile, &message);
+ if (r < 0) {
+ fprintf(stderr, "error encoding message, file not supported?\n");
+ goto out;
+ }
+
rnet_send(session, message->buffer, message->len, 1);
rnet_message_del(message);
rnet_send(session, message->buffer, message->len, 1);
rnet_message_del(message);