Examples of errors detected by the V692 diagnostic
V692. Inappropriate attempt to append a null character to a string. To determine the length of a string by 'strlen' function correctly, use a string ending with a null terminator in the first place.
Wine Is Not an Emulator
V692 An inappropriate attempt to append a null character to a string. To determine the length of a string by 'strlen' function correctly, a string ending with a null terminator should be used in the first place. appdefaults.c 390
static void on_remove_app_click(HWND dialog)
{
....
section[strlen(section)] = '\0'; /* remove last backslash */
....
}
'\0' is written to '\0'. Backslash will not be removed.
Linux Kernel
V692 An inappropriate attempt to append a null character to a string. To determine the length of a string by 'strlen' function correctly, a string ending with a null terminator should be used in the first place. ipr.c 9409
static void name_msi_vectors(struct ipr_ioa_cfg *ioa_cfg)
{
int vec_idx, n = sizeof(ioa_cfg->vectors_info[0].desc) - 1;
for (vec_idx = 0; vec_idx < ioa_cfg->nvectors; vec_idx++) {
snprintf(ioa_cfg->vectors_info[vec_idx].desc, n,
"host%d-%d", ioa_cfg->host->host_no, vec_idx);
ioa_cfg->vectors_info[vec_idx].
desc[strlen(ioa_cfg->vectors_info[vec_idx].desc)] = 0;
}
}
Haiku Operation System
V692 An inappropriate attempt to append a null character to a string. To determine the length of a string by 'strlen' function correctly, a string ending with a null terminator should be used in the first place. PoorManWindow.cpp 254
void
PoorManWindow::MessageReceived(BMessage* message)
{
....
if (inet_ntop(AF_INET, &sin_addr, addr, sizeof(addr)) != NULL){
addr[strlen(addr)] = '\0'; // <=
line << '(' << addr << ") ";
}
....
}
Tizen
V692 An inappropriate attempt to append a null character to a string. To determine the length of a string by 'strlen' function correctly, a string ending with a null terminator should be used in the first place. scmirroring_src.c 77
static int __scmirroring_src_send_cmd_to_server(
scmirroring_src_s *scmirroring, const char *cmd)
{
int ret = SCMIRRORING_ERROR_NONE;
char *_cmd = NULL;
....
_cmd = g_strdup(cmd);
if (_cmd == NULL) {
scmirroring_error("Out of memory for command buffer");
return SCMIRRORING_ERROR_OUT_OF_MEMORY;
}
_cmd[strlen(_cmd)] = '\0'; // <=
....
}
Similar errors can be found in some other places:
- V692 An inappropriate attempt to append a null character to a string. To determine the length of a string by 'strlen' function correctly, a string ending with a null terminator should be used in the first place. miracast_server_impl.c 183