Write a function to conduct input validation to secure the smallest buffer. You may call this function void SecurePasswordBuffer(const char *arg).
#include <iostream>
#include <string.h>
#include <cstdint>
#define BUF_SIZE 15//Example buffer size for secureBuf
using namespace std;
//Implement function ch
void SecurePasswordBuffer(const char*arg)
{
//Save buffer dont't remember bufsize 15 (defined) use #define
if(strlen(arg)>=BUF_SIZE)
{
printf("Error bufer\n");
abort();//ABORT SIGNAL
}
else{
printf("Normaly\n");
}
}
int main()
{
char bf[25];
printf("Input to buffer:");
scanf("%s",bf);
SecurePasswordBuffer(bf);
return 0;
}
Comments
Leave a comment