openbsd-ports/graphics/xzgv/patches/patch-src_help_c
alek 57b5969b4f Import xzgv 0.8
xzgv is a picture viewer for X, with a thumbnail-based file selector.
It uses GTK+ and Imlib. Most file formats are supported, and the
thumbnails used are compatible with xv, zgv, and the Gimp. It can also
be used with `xzgv file(s)', to effectively bypass the file selector.

From Julian Leyh <oenone@oenone.de>
2005-05-22 11:32:11 +00:00

46 lines
1.3 KiB
Plaintext

$OpenBSD: patch-src_help_c,v 1.1.1.1 2005/05/22 11:32:11 alek Exp $
--- src/help.c.orig Tue Sep 16 16:07:44 2003
+++ src/help.c Thu May 12 15:38:33 2005
@@ -84,8 +84,9 @@ void help_run(char *node)
char *cmd_start="xterm -e info '(xzgv)";
char *cmd_end="' &";
char *buf;
+int siz = strlen(cmd_start)+strlen(node)+strlen(cmd_end)+1;
-if((buf=malloc(strlen(cmd_start)+strlen(node)+strlen(cmd_end)+1))==NULL)
+if((buf=malloc(siz))==NULL)
{
/* if we're *that* low on memory, then error_dialog() will fail too,
* so just return.
@@ -93,9 +94,9 @@ if((buf=malloc(strlen(cmd_start)+strlen(
return;
}
-strcpy(buf,cmd_start);
-strcat(buf,node);
-strcat(buf,cmd_end);
+strlcpy(buf,cmd_start,siz);
+strlcat(buf,node,siz);
+strlcat(buf,cmd_end,siz);
/* XXX it turns out the error check is useless, as the `&' leads to
* starting another shell which is the one to give any errors. The
@@ -106,13 +107,14 @@ if(system(buf)!=0)
{
char *msg="Couldn't run help command:\n";
char *buf2;
+ int siz=strlen(msg)+strlen(buf)+1;
- if((buf2=malloc(strlen(msg)+strlen(buf)+1))==NULL)
+ if((buf2=malloc(siz))==NULL)
error_dialog("xzgv error",msg);
else
{
- strcpy(buf2,msg);
- strcat(buf2,buf);
+ strlcpy(buf2,msg,siz);
+ strlcat(buf2,buf,siz);
error_dialog("xzgv error",buf2);
free(buf2);
}