This commit fixes a bug that happens when the user provides a .DEC
filename to be transmitted, and rnetclient uses this filename to compose
the receipt (.REC) filename to be saved. I forgot to use "basename" to
extract only the .DEC filename (and strip all the other paths) before using
it to build the .REC full path. As an addition, this commit also fixes
a small memory leak. Tested by sending a declaration again.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
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') {
/* 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");
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);
} 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.