H
happy
I read an unanswered interview question somewhere :
#include <stdlib.h>
#include <stdio.h>
void Error(char* s)
{
printf(s);
return;
}
int main()
{
int *p;
p = (int*)malloc(sizeof(int));
if(!p)
{
Error("memory error");
Error("Quitting....\n");
exit(1);
}
else
{
/*some stuff to use p*/
}
free(p);
return 0;
}
Find potential problem with the error function.. a security concern..
Please tell me what can be the potential problem. Is this the printf
(p) because p can contain conversion specifiers?
#include <stdlib.h>
#include <stdio.h>
void Error(char* s)
{
printf(s);
return;
}
int main()
{
int *p;
p = (int*)malloc(sizeof(int));
if(!p)
{
Error("memory error");
Error("Quitting....\n");
exit(1);
}
else
{
/*some stuff to use p*/
}
free(p);
return 0;
}
Find potential problem with the error function.. a security concern..
Please tell me what can be the potential problem. Is this the printf
(p) because p can contain conversion specifiers?