Don't break if using the client-supplied filename
This commit is contained in:
parent
23f1eb2469
commit
bc43f07291
3 changed files with 9 additions and 6 deletions
|
@ -21,11 +21,6 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MIN
|
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
struct ethsock
|
struct ethsock
|
||||||
{
|
{
|
||||||
const char *intf;
|
const char *intf;
|
||||||
|
|
6
nmrp.c
6
nmrp.c
|
@ -213,16 +213,20 @@ static int msg_ntoh(struct nmrp_msg *msg)
|
||||||
|
|
||||||
static void *msg_opt_data(struct nmrp_msg *msg, int type, uint16_t *len)
|
static void *msg_opt_data(struct nmrp_msg *msg, int type, uint16_t *len)
|
||||||
{
|
{
|
||||||
|
static char buf[128];
|
||||||
struct nmrp_opt *opt = msg->opts;
|
struct nmrp_opt *opt = msg->opts;
|
||||||
int remaining = msg->len - NMRP_HDR_LEN;
|
int remaining = msg->len - NMRP_HDR_LEN;
|
||||||
|
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
while (remaining > 0) {
|
while (remaining > 0) {
|
||||||
if (opt->type == type) {
|
if (opt->type == type) {
|
||||||
if (opt->len == NMRP_OPT_LEN) {
|
if (opt->len == NMRP_OPT_LEN) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*len = opt->len - NMRP_OPT_LEN;
|
*len = opt->len - NMRP_OPT_LEN;
|
||||||
return (char*)&opt->val;
|
memcpy(buf, &opt->val, MIN(*len, sizeof(buf)-1));
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
remaining -= opt->len;
|
remaining -= opt->len;
|
||||||
|
|
4
nmrpd.h
4
nmrpd.h
|
@ -49,6 +49,10 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MIN
|
||||||
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
enum nmrp_op {
|
enum nmrp_op {
|
||||||
NMRP_UPLOAD_FW = 0,
|
NMRP_UPLOAD_FW = 0,
|
||||||
NMRP_UPLOAD_ST = 1,
|
NMRP_UPLOAD_ST = 1,
|
||||||
|
|
Loading…
Add table
Reference in a new issue