diff --git a/src/tftp.c b/src/tftp.c index 846b32e..ce7b56d 100644 --- a/src/tftp.c +++ b/src/tftp.c @@ -22,7 +22,7 @@ static void handle_tftp(time_t now, struct tftp_transfer *transfer, ssize_t len) static struct tftp_file *check_tftp_fileperm(ssize_t *len, char *prefix); static void free_transfer(struct tftp_transfer *transfer); static ssize_t tftp_err(int err, char *packet, char *message, char *file); -static ssize_t tftp_err_oops(char *packet, char *file); +static ssize_t tftp_err_oops(char *packet, const char *file); static ssize_t get_block(char *packet, struct tftp_transfer *transfer); static char *next(char **p, char *end); static void sanitise(char *buf); @@ -748,10 +748,11 @@ static ssize_t tftp_err(int err, char *packet, char *message, char *file) return ret; } -static ssize_t tftp_err_oops(char *packet, char *file) +static ssize_t tftp_err_oops(char *packet, const char *file) { /* May have >1 refs to file, so potentially mangle a copy of the name */ - strcpy(daemon->namebuff, file); + if (file != daemon->namebuff) + strcpy(daemon->namebuff, file); return tftp_err(ERR_NOTDEF, packet, _("cannot read %s: %s"), daemon->namebuff); }