fatal.c

来自「源码漏洞检查」· C语言 代码 · 共 47 行

C
47
字号
/* fatal.C * John Viega * * Jan 28-29 2000 */#include <stdio.h>#include "config.H"void OutOfMemory(){  fprintf(stderr, "Out of memory, sorry." NEWLINE);  exit(2);}void Perror(char *arg){  char *progname = GetProgramName();  char *buf;  int  size = strlen(progname) + strlen(arg)+2;  buf = new char[size];  if(!buf)    OutOfMemory();#ifdef HAVE_SNPRINTF  snprintf(buf, size, "%s:%s", progname, arg);#else  char *fmt_str = "%s:%s";  // u_bound off by 4 from actual answer.  int  u_bound  = strlen(fmt_str) + strlen(progname) + strlen(arg);  if(u_bound >= size)    {      char *tmp_sncp_buf = new char[u_bound];      if(!tmp_sncp_buf) OutOfMemory();      sprintf(tmp_sncp_buf, fmt_str, progname, arg); // ITS4: ignore      tmp_sncp_buf[size] = 0;      strcpy(buf, tmp_sncp_buf);  // ITS4: ignore      delete[] tmp_sncp_buf;    }  else    {      sprintf(buf, fmt_str, progname, arg);  // ITS4: ignore    }#endif  perror(buf);  delete[] buf;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?