The code I'm using should only give access to password byte however it gives it to bytebyte as well. I changed it from the original gets to fgets which solved a stacksmashing issue. What do I need to do to fix the new issue of bytebyte being excepted.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
// Use a struct to force local variable memory ordering
struct {
char buff[5];
char pass;
} localinfo;
localinfo.pass = 0;
printf("\n Enter the password:\n");
fgets(localinfo.buff, 5, stdin); // Get the password from the user
// Check the password with string matching
if(strcmp(localinfo.buff, "byte") !=0 ){
printf ("\n Wrong Password \n");
}
else {
printf ("\n Correct Password\n");
localinfo.pass = 1; // Set a flag denoting correct password
}
//IF password matches
// GIVE root or admin rights to user by checking for flag
if(localinfo.pass){
printf ("\n Congratulations! Root privileges given to the user!\n");
}
return 0;
}