Use "strlcpy" instead of "strncpy" and other Coverity issues
* Yet more nice way to fix Coverity issues fixed by hrev43460. Thanks Rene Gollent for pointing it out! * Potential Coverity issues fixed for sis19x driver too.
This commit is contained in:
@@ -337,10 +337,10 @@ Device::_MultiGetDescription(multi_description *multiDescription)
|
||||
Description.interface_version = B_CURRENT_INTERFACE_VERSION;
|
||||
Description.interface_minimum = B_CURRENT_INTERFACE_VERSION;
|
||||
|
||||
strncpy(Description.friendly_name, fInfo.Name(),
|
||||
sizeof(Description.friendly_name) - 1);
|
||||
strlcpy(Description.friendly_name, fInfo.Name(),
|
||||
sizeof(Description.friendly_name));
|
||||
|
||||
strncpy(Description.vendor_info, "Haiku.Inc.",
|
||||
strlcpy(Description.vendor_info, "Haiku.Inc.",
|
||||
sizeof(Description.vendor_info));
|
||||
|
||||
Description.output_channel_count = 2;
|
||||
|
||||
@@ -478,7 +478,7 @@ Mixer::_CreateMIXControlGroup(multi_mix_control_info* MultiInfo, int32& index,
|
||||
Controls[index].string = Info.fNameId;
|
||||
if (Info.fName != NULL)
|
||||
strlcpy(Controls[index].name, Info.fName,
|
||||
sizeof(Controls[index].name) - 1);
|
||||
sizeof(Controls[index].name));
|
||||
index++;
|
||||
|
||||
if (Info.fType & MIX_Mute) {
|
||||
@@ -549,7 +549,8 @@ Mixer::_CreateMIXControlGroup(multi_mix_control_info* MultiInfo, int32& index,
|
||||
Controls[index].flags = B_MULTI_MIX_MUX;
|
||||
Controls[index].parent = groupIndex;
|
||||
Controls[index].string = S_null;
|
||||
strlcpy(Controls[index].name, Info.fExName, sizeof(Controls[index].name));
|
||||
strlcpy(Controls[index].name, Info.fExName,
|
||||
sizeof(Controls[index].name));
|
||||
|
||||
TRACE("MUX:%#010x\n", Controls[index].id);
|
||||
index++;
|
||||
|
||||
@@ -79,7 +79,7 @@ void SiS7018_trace(bool force, const char* func, const char *fmt, ...)
|
||||
static char buffer[1024];
|
||||
char *buf_ptr = buffer;
|
||||
if (gLogFilePath == NULL) {
|
||||
strncpy(buffer, prefix, sizeof(buffer) - 1);
|
||||
strlcpy(buffer, prefix, sizeof(buffer));
|
||||
buf_ptr += strlen(prefix);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@ void create_log()
|
||||
return;
|
||||
|
||||
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
||||
close(open(gLogFilePath, flags, 0666));
|
||||
int fd = open(gLogFilePath, flags, 0666);
|
||||
if (fd > 0)
|
||||
close(fd);
|
||||
|
||||
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
||||
}
|
||||
@@ -91,7 +93,7 @@ void SiS19X_trace(bool force, const char* func, const char *fmt, ...)
|
||||
static char buffer[1024];
|
||||
char *buf_ptr = buffer;
|
||||
if (gLogFilePath == NULL) {
|
||||
strcpy(buffer, prefix);
|
||||
strlcpy(buffer, prefix, sizeof(buffer));
|
||||
buf_ptr += strlen(prefix);
|
||||
}
|
||||
|
||||
@@ -120,8 +122,10 @@ void SiS19X_trace(bool force, const char* func, const char *fmt, ...)
|
||||
|
||||
mutex_lock(&gLogLock);
|
||||
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
||||
if (fd > 0) {
|
||||
write(fd, buffer, strlen(buffer));
|
||||
close(fd);
|
||||
}
|
||||
mutex_unlock(&gLogLock);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ void usb_asix_trace(bool force, const char* func, const char *fmt, ...)
|
||||
static char buffer[1024];
|
||||
char *buf_ptr = buffer;
|
||||
if (gLogFilePath == NULL) {
|
||||
strncpy(buffer, prefix, sizeof(buffer) - 1);
|
||||
strlcpy(buffer, prefix, sizeof(buffer));
|
||||
buf_ptr += strlen(prefix);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ void usb_davicom_trace(bool force, const char* func, const char *fmt, ...)
|
||||
static char buffer[1024];
|
||||
char *buf_ptr = buffer;
|
||||
if (gLogFilePath == NULL) {
|
||||
strncpy(buffer, prefix, sizeof(buffer) - 1);
|
||||
strlcpy(buffer, prefix, sizeof(buffer));
|
||||
buf_ptr += strlen(prefix);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user