openbsd-ports/graphics/xzgv/patches/patch-src_filedetails_c
ajacoutot 57f0b5d904 SECURITY - fix a heap overflow
While here:
- remove quotes around COMMENT
- change MAINTAINER's email
- update patches
- reformat dependencies/WANTLIB
- don't use hardcoded patches in man and info pages

based on a diff from Julian Leyh <julian at vgai dot de> (MAINTAINER)
2007-07-17 12:45:49 +00:00

80 lines
2.2 KiB
Plaintext

$OpenBSD: patch-src_filedetails_c,v 1.2 2007/07/17 12:45:49 ajacoutot Exp $
--- src/filedetails.c.orig Sat Nov 18 18:58:39 2000
+++ src/filedetails.c Tue Jul 17 14:26:29 2007
@@ -26,7 +26,7 @@ static char buf[10];
int f,shift,submode;
char *execptr;
-strcpy(buf,"---------");
+strlcpy(buf,"---------",sizeof(buf));
for(f=0,shift=6;f<3;f++,shift-=3)
{
@@ -73,14 +73,14 @@ char *ptr;
if((ptr=strrchr(filename,'/'))==NULL)
{
- strcpy(buf,".xvpics/");
- strcat(buf,filename);
+ strlcpy(buf,".xvpics/",sizeof(buf));
+ strlcat(buf,filename,sizeof(buf));
}
else
{
- strcpy(buf,filename);
- strcpy(strrchr(buf,'/')+1,".xvpics/");
- strcat(buf,ptr+1);
+ strlcpy(buf,filename,sizeof(buf));
+ strlcat(buf,".xvpics/",sizeof(buf));
+ strlcat(buf,ptr+1,sizeof(buf));
}
if((tn=fopen(buf,"rb"))!=NULL)
@@ -174,11 +174,11 @@ DO_TBL_LEFT(os_tbl,tbl_row,"Filename:");
DO_TBL_RIGHT(os_tbl,tbl_row,filename);
tbl_row++;
-strcpy(buf,"unknown");
+strlcpy(buf,"unknown",sizeof(buf));
DO_TBL_LEFT(os_tbl,tbl_row,"Size:");
if(got_stat_info)
- sprintf(buf,"%d (%dk)",(int)sbuf.st_size,((int)sbuf.st_size+1023)/1024);
+ snprintf(buf,sizeof(buf),"%d (%dk)",(int)sbuf.st_size,((int)sbuf.st_size+1023)/1024);
DO_TBL_RIGHT(os_tbl,tbl_row,buf);
tbl_row++;
@@ -186,9 +186,9 @@ DO_TBL_LEFT(os_tbl,tbl_row,"Last modified:");
if(got_stat_info)
{
if((ctime=localtime(&sbuf.st_mtime))==NULL) /* can't happen? */
- strcpy(buf,"unknown");
+ strlcpy(buf,"unknown",sizeof(buf));
else
- sprintf(buf,"%d-%02d-%02d %02d:%02d",
+ snprintf(buf,sizeof(buf),"%d-%02d-%02d %02d:%02d",
1900+ctime->tm_year,ctime->tm_mon+1,ctime->tm_mday,
ctime->tm_hour,ctime->tm_min);
}
@@ -197,7 +197,7 @@ tbl_row++;
DO_TBL_LEFT(os_tbl,tbl_row,"Permissions:");
if(got_stat_info)
- sprintf(buf,"%s (%o)",
+ snprintf(buf,sizeof(buf),"%s (%o)",
make_perms_string(sbuf.st_mode&07777),sbuf.st_mode&07777);
DO_TBL_RIGHT(os_tbl,tbl_row,buf);
tbl_row++;
@@ -232,9 +232,9 @@ tbl_row=0;
DO_TBL_LEFT(tn_tbl,tbl_row,"Dimensions:");
if(got_dimensions)
- sprintf(buf,"%d x %d",w,h);
+ snprintf(buf,sizeof(buf),"%d x %d",w,h);
else
- strcpy(buf,"unknown");
+ strlcpy(buf,"unknown",sizeof(buf));
DO_TBL_RIGHT(tn_tbl,tbl_row,buf);
tbl_row++;