Skip to content

Instantly share code, notes, and snippets.

@eqdw
Created March 20, 2011 22:40
Show Gist options
  • Save eqdw/878755 to your computer and use it in GitHub Desktop.
Save eqdw/878755 to your computer and use it in GitHub Desktop.
#define MSG_FORMAT "%s cannot be authenticated.\n"
void incorrect_password(const char *user)
{
// user names are restricted to 256 characters (or less)
static const char *msg_format = MSG_FORMAT;
size_t len = strlen(user) + sizeof(MSG_FORMAT);
char *msg = (char *)malloc(len);
if (msg)
{
int ret = snprintf(msg, len, msg_format, user);
if (ret>=0 && ret<len)
fprintf(stderr, msg);
free(msg);
msg = NULL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment