2
0
forked from Ivasoft/DSView

set strncpy buffer size

This commit is contained in:
dreamsourcelabTAI
2023-06-26 17:55:03 +08:00
parent be3f578ce5
commit c48e6bae75
3 changed files with 3 additions and 3 deletions

View File

@@ -930,7 +930,7 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod
assert(false);
}
char buf[25];
strncpy(buf, id, sizeof(buf));
strncpy(buf, id, sizeof(buf)-1);
char *rd = buf;
char *start = NULL;
int len = 0;

View File

@@ -500,7 +500,7 @@ XLOG_API int xlog_set_domain(xlog_writer* wr, const char *domain)
wr->_domain[0] = '\0';
if (domain && *domain){
strncpy(wr->_domain, domain, sizeof(wr->_domain));
strncpy(wr->_domain, domain, sizeof(wr->_domain) - 1);
}
return 0;
}

View File

@@ -202,7 +202,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int mode, int status,
}
if (model && *model){
strncpy(sdi->name, model, sizeof(sdi->name));
strncpy(sdi->name, model, sizeof(sdi->name)-1);
}
return sdi;