[MPlayer-dev-eng] [PATCH] add a limit

adland adland123 at yahoo.com
Tue Mar 22 03:35:41 CET 2005


small update  - add limit to whatever getenv returns

--- main/osdep/getch2.c	2004-04-05 17:33:08.000000000 -0400
+++ updated/osdep/getch2.c	2005-03-21 21:08:36.000000000 -0500
@@ -9,6 +9,7 @@

#define MAX_KEYS 64
#define BUF_LEN 256
+#define MP_TERM_MAXSIZE 80 

#include <stdio.h>
#include <stdlib.h>
@@ -78,9 +79,12 @@
static int success=0;

int load_termcap(char *termtype){
+  char mp_termtype[MP_TERM_MAXSIZE];
if(!termtype) termtype=getenv("TERM");
if(!termtype) termtype="unknown";
-  success=tgetent(term_buffer, termtype);
+  memset(mp_termtype,0,MP_TERM_MAXSIZE); // make sure string is terminated
+  strncpy(mp_termtype,termtype,MP_TERM_MAXSIZE-1);
+  success=tgetent(term_buffer, mp_termtype);
   if(success<0){ printf("Could not access the 'termcap' data base.\n"); return
0; }
   if(success==0){ printf("Terminal type `%s' is not defined.\n", termtype);ret
urn 0;}






More information about the MPlayer-dev-eng mailing list