Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
langc
char *source = "0123456789abcdef";
char ntbs[NTBS_SIZE];
/* ... */
if (source) {
  if (strlen(source) < sizeof(ntbs)) {
    strcpy(ntbs, source);
  }
  else {
    /* handleHandle string too large condition */
  }
}
else {
  /* handleHandle NULL string condition */
}

...

Code Block
bgColor#ccccff
langc
char *source;
char a[NTBS_SIZE];
/* ... */
if (source) {
  errno_t err = strncpy_s(a, sizeof(a), source, 5);
  if (err != 0) {
    /* Handle error */
  }
}
else {
  /* handleHandle NULL string condition */
}

...

Tool

Version

Checker

Description

Compass/ROSE

 

 

Can detect some violations of this rule.

Coverity6.5STRING_NULLFully Implemented.

Klocwork

Include Page
Klocwork_V
Klocwork_V

NNTS

 

LDRA tool suite

Include Page
LDRA_V
LDRA_V

600 S

Fully implemented.

...

Bibliography

[Schwarz 2005] 
[Seacord 2005a2013] Chapter 2, "Strings" 
[Viega 2005]Section 5.2.14, "Miscalculated NULL Termination"

...