Read a full line and detect exact-fit versus truncation

The fragment is intended to read one full name, including spaces, into capacity eight and remove only an input newline. Diagnose why it cannot meet that contract; do not run it on unsafe input. Write a replacement full program for ordinary text without embedded null characters. Accept a first line with 0..7 text characters, terminated by newline or EOF, and print length|text followed by a newline. With no characters available at EOF, print NO INPUT. If the line has more than seven text characters, consume the rest of that line and print TOO LONG. Distinguish seven characters followed by newline from a genuinely longer line. Examples: Ada Lov is exactly seven characters; Ada Love is eight. No interactive prompts are printed.

char name[8];
scanf("%s", name);
name[strlen(name) - 1] = '\0';
printf("[%s]\n", name);

