Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 597 Bytes

Overflow6.c.md

File metadata and controls

24 lines (18 loc) · 597 Bytes

Question

What is the problem here?

char *lccopy(const char *str) {
  char buf[64];
  char *p;

  strcpy(buf, str);
  for (p = buf; *p; p++) {
    if (isupper(*p)) {
      *p = tolower(*p);
    }
  }
  return strdup(buf);
}

-----SPLIT-----

Answer

It is an Buffer Overflow issue. The function takes a string as its argument and returns a heap-allocated copy of the string with all uppercase letters converted to lowercase. However, no size control takes place and anything more than 64 chars size causes the issue. https://owasp.org/www-community/vulnerabilities/Buffer_Overflow