49bc284aaa
Also, make driver more robust, by separating gain control (which often does not work) from main setup.
52 lines
1.2 KiB
Plaintext
52 lines
1.2 KiB
Plaintext
$OpenBSD: patch-src_api_load_c,v 1.1 2001/04/05 19:31:42 espie Exp $
|
|
--- src/api/load.c.orig Thu Apr 5 20:54:02 2001
|
|
+++ src/api/load.c Thu Apr 5 20:59:30 2001
|
|
@@ -14,6 +14,8 @@
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
+#include <sys/types.h>
|
|
+#include <sys/stat.h>
|
|
#include "xmpi.h"
|
|
#include "xxm.h"
|
|
|
|
@@ -26,7 +28,8 @@ extern struct xmp_fmt_info *__fmt_head;
|
|
extern struct xmp_ord_info xmpi_oinfo[256];
|
|
extern int __pause;
|
|
|
|
-static char *temp;
|
|
+static char tmplate[] = "/tmp/xmp.XXXXXXXXXX";
|
|
+static char temp[50];
|
|
|
|
|
|
static int decompress (char **mod, char *suffix, char *decomp)
|
|
@@ -56,8 +59,14 @@ int xmp_load_module (char *s)
|
|
FILE *f;
|
|
int i, t;
|
|
struct xmp_fmt_info *fmt;
|
|
-
|
|
- temp = tempnam (NULL, "xmp_");
|
|
+ int fd;
|
|
+ struct stat buf;
|
|
+
|
|
+ strcpy(temp, tmplate);
|
|
+ fd = mkstemp(temp);
|
|
+ if (fd == -1)
|
|
+ return -3;
|
|
+ close(fd);
|
|
|
|
if ((decompress (&s, ".gz", "gzip -dc") *
|
|
decompress (&s, ".Z", "uncompress -c") *
|
|
@@ -71,6 +80,11 @@ int xmp_load_module (char *s)
|
|
if ((f = fopen (s, "r")) == NULL)
|
|
return -3;
|
|
|
|
+ if (fstat(fileno(f), &buf) == -1 || buf.st_size == 0) {
|
|
+ fclose(f);
|
|
+ return -3;
|
|
+ }
|
|
+
|
|
drv->clearmem ();
|
|
|
|
opt.filename = s; /* For ALM */
|