summaryrefslogtreecommitdiff
path: root/gnu/usr.sbin/mkhybrid
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2008-02-27 09:59:53 +0000
committerMarc Espie <espie@cvs.openbsd.org>2008-02-27 09:59:53 +0000
commit1ff1e51b7310dede9335e0c16c80fbae91744772 (patch)
tree22d0d365f5a1135a7c97a9ddd5dec12dd099c845 /gnu/usr.sbin/mkhybrid
parent2d75e87978a16f807e13bdf56b7d2a06d734f935 (diff)
start cleaning up that mess (some sprintf -> snprintf, plus -Wall)
okay millert@
Diffstat (limited to 'gnu/usr.sbin/mkhybrid')
-rw-r--r--gnu/usr.sbin/mkhybrid/src/apple.h3
-rw-r--r--gnu/usr.sbin/mkhybrid/src/libfile/softmagic.c17
-rw-r--r--gnu/usr.sbin/mkhybrid/src/libhfs_iso/block.c4
-rw-r--r--gnu/usr.sbin/mkhybrid/src/libhfs_iso/hfs.c3
-rw-r--r--gnu/usr.sbin/mkhybrid/src/libhfs_iso/hybrid.h2
-rw-r--r--gnu/usr.sbin/mkhybrid/src/libhfs_iso/record.c1
-rw-r--r--gnu/usr.sbin/mkhybrid/src/mac_label.c21
-rw-r--r--gnu/usr.sbin/mkhybrid/src/match.h3
-rw-r--r--gnu/usr.sbin/mkhybrid/src/mkisofs.c3
-rw-r--r--gnu/usr.sbin/mkhybrid/src/tree.c18
-rw-r--r--gnu/usr.sbin/mkhybrid/src/volume.c28
-rw-r--r--gnu/usr.sbin/mkhybrid/src/write.c14
12 files changed, 63 insertions, 54 deletions
diff --git a/gnu/usr.sbin/mkhybrid/src/apple.h b/gnu/usr.sbin/mkhybrid/src/apple.h
index 9eabf138826..56aed612c06 100644
--- a/gnu/usr.sbin/mkhybrid/src/apple.h
+++ b/gnu/usr.sbin/mkhybrid/src/apple.h
@@ -50,6 +50,9 @@ typedef struct {
unsigned short fdflags; /* finder flags */
} afpmap;
+extern void hfs_init(char *, unsigned short, int, int, unsigned int);
+extern void clean_hfs(void);
+
/* from "data.h" - libhfs routines */
unsigned long d_toutime(unsigned long);
long d_getl(unsigned char *);
diff --git a/gnu/usr.sbin/mkhybrid/src/libfile/softmagic.c b/gnu/usr.sbin/mkhybrid/src/libfile/softmagic.c
index d667dd576d5..c87571c29ec 100644
--- a/gnu/usr.sbin/mkhybrid/src/libfile/softmagic.c
+++ b/gnu/usr.sbin/mkhybrid/src/libfile/softmagic.c
@@ -43,7 +43,7 @@
#ifndef lint
static char *moduleid =
- "@(#)$Id: softmagic.c,v 1.1 2000/10/10 20:40:37 beck Exp $";
+ "@(#)$Id: softmagic.c,v 1.2 2008/02/27 09:59:52 espie Exp $";
#endif /* lint */
/* static int match __P((unsigned char *, int)); */
@@ -51,8 +51,6 @@ static char *match __P((unsigned char *, int));
static int mget __P((union VALUETYPE *,
unsigned char *, struct magic *, int));
static int mcheck __P((union VALUETYPE *, struct magic *));
-static int32 mprint __P((union VALUETYPE *, struct magic *));
-static void mdebug __P((int32, char *, int));
static int mconvert __P((union VALUETYPE *, struct magic *));
/*
@@ -102,7 +100,6 @@ unsigned char *s;
int nbytes;
{
int magindex = 0;
- int cont_level = 0;
union VALUETYPE p;
for (magindex = 0; magindex < nmagic; magindex++) {
@@ -171,18 +168,6 @@ struct magic *m;
}
-static void
-mdebug(offset, str, len)
-int32 offset;
-char *str;
-int len;
-{
- (void) fprintf(stderr, "mget @%d: ", offset);
- showstr(stderr, (char *) str, len);
- (void) fputc('\n', stderr);
- (void) fputc('\n', stderr);
-}
-
static int
mget(p, s, m, nbytes)
union VALUETYPE* p;
diff --git a/gnu/usr.sbin/mkhybrid/src/libhfs_iso/block.c b/gnu/usr.sbin/mkhybrid/src/libhfs_iso/block.c
index f4df0c94186..2fce872e45c 100644
--- a/gnu/usr.sbin/mkhybrid/src/libhfs_iso/block.c
+++ b/gnu/usr.sbin/mkhybrid/src/libhfs_iso/block.c
@@ -38,7 +38,6 @@
*/
int b_readlb(hfsvol *vol, unsigned long num, block *bp)
{
- int bytes;
#ifdef APPLE_HYB
block *b;
hce_mem *hce;
@@ -67,6 +66,7 @@ int b_readlb(hfsvol *vol, unsigned long num, block *bp)
memcpy(bp, b, HFS_BLOCKSZ);
#else
+ int bytes;
if (lseek(vol->fd, (vol->vstart + num) * HFS_BLOCKSZ, SEEK_SET) < 0)
{
@@ -100,7 +100,6 @@ int b_readlb(hfsvol *vol, unsigned long num, block *bp)
*/
int b_writelb(hfsvol *vol, unsigned long num, block *bp)
{
- int bytes;
#ifdef APPLE_HYB
block *b;
hce_mem *hce;
@@ -131,6 +130,7 @@ int b_writelb(hfsvol *vol, unsigned long num, block *bp)
memcpy(b, bp, HFS_BLOCKSZ);
#else
+ int bytes;
if (lseek(vol->fd, (vol->vstart + num) * HFS_BLOCKSZ, SEEK_SET) < 0)
{
diff --git a/gnu/usr.sbin/mkhybrid/src/libhfs_iso/hfs.c b/gnu/usr.sbin/mkhybrid/src/libhfs_iso/hfs.c
index bf4e6be5b8f..5aebc084a7c 100644
--- a/gnu/usr.sbin/mkhybrid/src/libhfs_iso/hfs.c
+++ b/gnu/usr.sbin/mkhybrid/src/libhfs_iso/hfs.c
@@ -55,10 +55,11 @@ hfsvol *hfs_mount(hce_mem *hce, int pnum, int flags)
hfsvol *hfs_mount(char *path, int pnum, int flags)
#endif /* APPLE_HYB */
{
- struct stat dev;
hfsvol *vol = 0;
#ifndef APPLE_HYB
+
+ struct stat dev;
/* see if the volume is already mounted */
if (stat(path, &dev) >= 0)
diff --git a/gnu/usr.sbin/mkhybrid/src/libhfs_iso/hybrid.h b/gnu/usr.sbin/mkhybrid/src/libhfs_iso/hybrid.h
index baa2fa68406..8eac79ea3ae 100644
--- a/gnu/usr.sbin/mkhybrid/src/libhfs_iso/hybrid.h
+++ b/gnu/usr.sbin/mkhybrid/src/libhfs_iso/hybrid.h
@@ -33,5 +33,7 @@ typedef struct {
char *error; /* HFS error message */
} hce_mem;
+#define ERROR_SIZE 1024
+
#define _HYBRID_H
#endif /* _HYBRID_H */
diff --git a/gnu/usr.sbin/mkhybrid/src/libhfs_iso/record.c b/gnu/usr.sbin/mkhybrid/src/libhfs_iso/record.c
index 8c45001e82f..e99d8bb2f3d 100644
--- a/gnu/usr.sbin/mkhybrid/src/libhfs_iso/record.c
+++ b/gnu/usr.sbin/mkhybrid/src/libhfs_iso/record.c
@@ -19,6 +19,7 @@
# include <string.h>
# include <errno.h>
+# include <stdlib.h>
# include "internal.h"
# include "data.h"
diff --git a/gnu/usr.sbin/mkhybrid/src/mac_label.c b/gnu/usr.sbin/mkhybrid/src/mac_label.c
index 5ed04855a6f..c92d54e0831 100644
--- a/gnu/usr.sbin/mkhybrid/src/mac_label.c
+++ b/gnu/usr.sbin/mkhybrid/src/mac_label.c
@@ -41,18 +41,21 @@ gen_mac_label(defer *mac_boot)
/* If we have a boot file, then open and check it */
if (mac_boot->name) {
if (stat(mac_boot->name, &stat_buf) < 0) {
- sprintf(hce->error,"unable to stat HFS boot file %s", mac_boot->name);
+ snprintf(hce->error, ERROR_SIZE,
+ "unable to stat HFS boot file %s", mac_boot->name);
return (-1);
}
if ((fp = fopen(mac_boot->name, "rb")) == NULL) {
- sprintf(hce->error,"unable to open HFS boot file %s", mac_boot->name);
+ snprintf(hce->error, ERROR_SIZE,
+ "unable to open HFS boot file %s", mac_boot->name);
return (-1);
}
if (fread(tmp, 1, SECTOR_SIZE, fp) != SECTOR_SIZE) {
- sprintf(hce->error,"unable to read HFS boot file %s", mac_boot->name);
+ snprintf(hce->error, ERROR_SIZE,
+ "unable to read HFS boot file %s", mac_boot->name);
return (-1);
}
@@ -61,20 +64,23 @@ gen_mac_label(defer *mac_boot)
mac_part = (MacPart*)(tmp+HFS_BLOCKSZ);
if (!(IS_MAC_PART(mac_part) && !strncmp(mac_part->pmPartType, pmPartType_2, 12))) {
- sprintf(hce->error,"%s is not a HFS boot file", mac_boot->name);
+ snprintf(hce->error, ERROR_SIZE, "%s is not a HFS boot file",
+ mac_boot->name);
return (-1);
}
/* check we have a boot block as well - last 2 blocks of file */
if (fseek(fp, -2 * HFS_BLOCKSZ, 2) != 0) {
- sprintf(hce->error,"unable to seek HFS boot file %s", mac_boot->name);
+ snprintf(hce->error, ERROR_SIZE,
+ "unable to seek HFS boot file %s", mac_boot->name);
return (-1);
}
/* overwrite (empty) boot block for our HFS volume */
if (fread(hce->hfs_hdr, 2, HFS_BLOCKSZ, fp) != HFS_BLOCKSZ) {
- sprintf(hce->error,"unable to read HFS boot block %s", mac_boot->name);
+ snprintf(hce->error, ERROR_SIZE,
+ "unable to read HFS boot block %s", mac_boot->name);
return (-1);
}
@@ -82,7 +88,8 @@ gen_mac_label(defer *mac_boot)
/* check boot block is valid */
if (d_getw((unsigned char *)hce->hfs_hdr) != HFS_BB_SIGWORD) {
- sprintf(hce->error,"%s does not contain a valid boot block", mac_boot->name);
+ snprintf(hce->error, ERROR_SIZE,
+ "%s does not contain a valid boot block", mac_boot->name);
return (-1);
}
diff --git a/gnu/usr.sbin/mkhybrid/src/match.h b/gnu/usr.sbin/mkhybrid/src/match.h
index 404872dd85f..696028a9551 100644
--- a/gnu/usr.sbin/mkhybrid/src/match.h
+++ b/gnu/usr.sbin/mkhybrid/src/match.h
@@ -5,7 +5,7 @@
*/
/*
- * $Id: match.h,v 1.2 2002/11/03 20:27:03 pvalchev Exp $
+ * $Id: match.h,v 1.3 2008/02/27 09:59:51 espie Exp $
*/
#include <inttypes.h>
@@ -25,6 +25,7 @@ int i_add_match __PR((char *fn));
int j_add_match __PR((char *fn));
int hfs_add_match __PR((char *fn));
+void hfs_add_list __PR((char *fn));
int hfs_matches __PR((char *fn));
intptr_t hfs_ishidden __PR((void));
diff --git a/gnu/usr.sbin/mkhybrid/src/mkisofs.c b/gnu/usr.sbin/mkhybrid/src/mkisofs.c
index 99b78e16eb4..c9fb11d481c 100644
--- a/gnu/usr.sbin/mkhybrid/src/mkisofs.c
+++ b/gnu/usr.sbin/mkhybrid/src/mkisofs.c
@@ -20,7 +20,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-static char rcsid[] ="$Id: mkisofs.c,v 1.3 2001/10/01 17:05:05 drahn Exp $";
+static char rcsid[] ="$Id: mkisofs.c,v 1.4 2008/02/27 09:59:51 espie Exp $";
/* APPLE_HYB James Pearson j.pearson@ge.ucl.ac.uk 12/3/99 */
@@ -1140,7 +1140,6 @@ parse_input_files:
#if defined(__NetBSD__) || defined(__OpenBSD__)
{
- int resource;
struct rlimit rlp;
if (getrlimit(RLIMIT_DATA,&rlp) == -1)
perror("Warning: getrlimit");
diff --git a/gnu/usr.sbin/mkhybrid/src/tree.c b/gnu/usr.sbin/mkhybrid/src/tree.c
index db5d93f0176..f740a622b2f 100644
--- a/gnu/usr.sbin/mkhybrid/src/tree.c
+++ b/gnu/usr.sbin/mkhybrid/src/tree.c
@@ -20,7 +20,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-static char rcsid[] ="$Id: tree.c,v 1.2 2003/05/08 21:04:17 vincent Exp $";
+static char rcsid[] ="$Id: tree.c,v 1.3 2008/02/27 09:59:51 espie Exp $";
/* ADD_FILES changes made by Ross Biro biro@yggdrasil.com 2/23/95 */
@@ -260,7 +260,7 @@ static int FDECL1(sort_n_finish, struct directory *, this_dir)
{
for(d3 = 0; d3 < 36; d3++)
{
- sprintf(newname,"%s.%c%c%c%s", rootname,
+ snprintf(newname, sizeof newname, "%s.%c%c%c%s", rootname,
(d1 <= 9 ? '0' + d1 : 'A' + d1 - 10),
(d2 <= 9 ? '0' + d2 : 'A' + d2 - 10),
(d3 <= 9 ? '0' + d3 : 'A' + d3 - 10),
@@ -1526,7 +1526,7 @@ FDECL3(insert_file_entry,struct directory *, this_dir,
switch(lstatbuf.st_mode & S_IFMT)
{
case S_IFDIR:
- sprintf(buffer,"D\t%s\n",
+ snprintf(buffer, sizeof buffer, "D\t%s\n",
s_entry->name);
break;
#ifdef S_IFBLK
@@ -1548,7 +1548,7 @@ FDECL3(insert_file_entry,struct directory *, this_dir,
(dev) & 0xffffffff))
#endif
case S_IFBLK:
- sprintf(buffer,"B\t%s\t%lu %lu\n",
+ snprintf(buffer, sizeof buffer, "B\t%s\t%lu %lu\n",
s_entry->name,
(unsigned long) major(statbuf.st_rdev),
(unsigned long) minor(statbuf.st_rdev));
@@ -1556,13 +1556,13 @@ FDECL3(insert_file_entry,struct directory *, this_dir,
#endif
#ifdef S_IFIFO
case S_IFIFO:
- sprintf(buffer,"P\t%s\n",
+ snprintf(buffer, sizeof buffer, "P\t%s\n",
s_entry->name);
break;
#endif
#ifdef S_IFCHR
case S_IFCHR:
- sprintf(buffer,"C\t%s\t%lu %lu\n",
+ snprintf(buffer, sizeof buffer, "C\t%s\t%lu %lu\n",
s_entry->name,
(unsigned long) major(statbuf.st_rdev),
(unsigned long) minor(statbuf.st_rdev));
@@ -1574,19 +1574,19 @@ FDECL3(insert_file_entry,struct directory *, this_dir,
(char *)symlink_buff,
sizeof(symlink_buff)-1);
symlink_buff[nchar < 0 ? 0 : nchar] = 0;
- sprintf(buffer,"L\t%s\t%s\n",
+ snprintf(buffer, sizeof buffer, "L\t%s\t%s\n",
s_entry->name, symlink_buff);
break;
#endif
#ifdef S_IFSOCK
case S_IFSOCK:
- sprintf(buffer,"S\t%s\n",
+ snprintf(buffer, sizeof buffer, "S\t%s\n",
s_entry->name);
break;
#endif
case S_IFREG:
default:
- sprintf(buffer,"F\t%s\n",
+ snprintf(buffer, sizeof buffer, "F\t%s\n",
s_entry->name);
break;
};
diff --git a/gnu/usr.sbin/mkhybrid/src/volume.c b/gnu/usr.sbin/mkhybrid/src/volume.c
index 056e8e3fc19..8416cd5aa1a 100644
--- a/gnu/usr.sbin/mkhybrid/src/volume.c
+++ b/gnu/usr.sbin/mkhybrid/src/volume.c
@@ -190,7 +190,8 @@ int FDECL2(make_mac_volume, struct directory *, dpnt, int, start_extent)
else {
/* allocation size has changed, so update ISO volume size */
if ((vlen = get_adj_size(Csize)) < 0) {
- sprintf(hce->error,"too many files for HFS volume");
+ snprintf(hce->error, ERROR_SIZE,
+ "too many files for HFS volume");
return (-1);
}
vlen += V_ROUND_UP(start_extent * SECTOR_SIZE, Csize);
@@ -211,7 +212,7 @@ int FDECL2(make_mac_volume, struct directory *, dpnt, int, start_extent)
/* format and mount the "volume" */
if (hfs_format(hce, 0, vol_name) < 0)
{
- sprintf(hce->error,"can't HFS format %s",vol_name);
+ snprintf(hce->error, ERROR_SIZE, "can't HFS format %s",vol_name);
return(-1);
}
@@ -224,7 +225,7 @@ int FDECL2(make_mac_volume, struct directory *, dpnt, int, start_extent)
if ((vol = hfs_mount(hce, 0, 0)) == 0)
{
- sprintf(hce->error,"can't HFS mount %s",vol_name);
+ snprintf(hce->error, ERROR_SIZE, "can't HFS mount %s",vol_name);
return(-1);
}
@@ -327,7 +328,8 @@ int FDECL2(copy_to_mac_vol, hfsvol *, vol, struct directory *, node)
{
/* not an "exist" error, or we can't append as
the filename is already HFS_MAX_FLEN chars */
- sprintf(hce->error, "can't HFS create file %s",
+ snprintf(hce->error, ERROR_SIZE,
+ "can't HFS create file %s",
s_entry->whole_name);
return(-1);
}
@@ -366,7 +368,8 @@ int FDECL2(copy_to_mac_vol, hfsvol *, vol, struct directory *, node)
/* open file */
if ((hfp = hfs_open(vol, ent->name)) == 0)
{
- sprintf(hce->error, "can't HFS open %s", s_entry->whole_name);
+ snprintf(hce->error, ERROR_SIZE, "can't HFS open %s",
+ s_entry->whole_name);
return(-1);
}
@@ -385,7 +388,7 @@ int FDECL2(copy_to_mac_vol, hfsvol *, vol, struct directory *, node)
/* update any HFS file attributes */
if ((hfs_fsetattr(hfp, ent)) < 0)
{
- sprintf(hce->error, "can't HFS set attributes %s",
+ snprintf(hce->error, ERROR_SIZE, "can't HFS set attributes %s",
s_entry->whole_name);
return(-1);
}
@@ -407,7 +410,7 @@ int FDECL2(copy_to_mac_vol, hfsvol *, vol, struct directory *, node)
/* close the file and update the starting blocks */
if (hfs_close(hfp, dext, rext) < 0)
{
- sprintf(hce->error, "can't HFS close file %s",
+ snprintf(hce->error, ERROR_SIZE, "can't HFS close file %s",
s_entry->whole_name);
return(-1);
}
@@ -434,7 +437,9 @@ int FDECL2(copy_to_mac_vol, hfsvol *, vol, struct directory *, node)
/* have a problem - can't find the real directory */
if(s_entry1 == NULL)
{
- sprintf(hce->error, "can't locate relocated directory %s", s_entry->whole_name);
+ snprintf(hce->error, ERROR_SIZE,
+ "can't locate relocated directory %s",
+ s_entry->whole_name);
return(-1);
}
}
@@ -456,7 +461,9 @@ int FDECL2(copy_to_mac_vol, hfsvol *, vol, struct directory *, node)
dpnt = dpnt->next;
if(!dpnt)
{
- sprintf(hce->error, "can't find directory location %s", s_entry1->whole_name);
+ snprintf(hce->error, ERROR_SIZE,
+ "can't find directory location %s",
+ s_entry1->whole_name);
return (-1);
}
}
@@ -485,7 +492,8 @@ int FDECL2(copy_to_mac_vol, hfsvol *, vol, struct directory *, node)
{
/* not an "exist" error, or we can't append as
the filename is already HFS_MAX_FLEN chars */
- sprintf(hce->error, "can't HFS create folder %s",
+ snprintf(hce->error, ERROR_SIZE,
+ "can't HFS create folder %s",
s_entry->whole_name);
return(-1);
}
diff --git a/gnu/usr.sbin/mkhybrid/src/write.c b/gnu/usr.sbin/mkhybrid/src/write.c
index f9f17a78c6f..d132819b34e 100644
--- a/gnu/usr.sbin/mkhybrid/src/write.c
+++ b/gnu/usr.sbin/mkhybrid/src/write.c
@@ -19,7 +19,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-static char rcsid[] ="$Id: write.c,v 1.1 2000/10/10 20:40:22 beck Exp $";
+static char rcsid[] ="$Id: write.c,v 1.2 2008/02/27 09:59:51 espie Exp $";
/* APPLE_HYB James Pearson j.pearson@ge.ucl.ac.uk 16/3/1999 */
#include <string.h>
@@ -148,7 +148,7 @@ void FDECL4(xfwrite, void *, buffer, int, count, int, size, FILE *, file)
if (idx == 0)
unlink(outfile);
- sprintf(nbuf, "%s_%02d", outfile, idx++);
+ snprintf(nbuf, sizeof nbuf, "%s_%02d", outfile, idx++);
file = freopen(nbuf, "wb", file);
if (file == NULL) {
fprintf(stderr, "Cannot open '%s'.\n", nbuf);
@@ -711,11 +711,12 @@ static void FDECL1(assign_file_addresses, struct directory *, dpnt)
dwpnt->table = s_entry->table;
dwpnt->name = NULL;
#ifdef APPLE_HYB
- sprintf(whole_path,"%s%s%s",
+ snprintf(whole_path, sizeof whole_path, "%s%s%s",
s_entry->filedir->whole_name, SPATH_SEPARATOR,
trans_tbl);
#else
- sprintf(whole_path,"%s%sTRANS.TBL",
+ snprintf(whole_path, sizeof whole_path,
+ "%s%sTRANS.TBL",
s_entry->filedir->whole_name, SPATH_SEPARATOR);
#endif /* APPLE_HYB */
}
@@ -1325,7 +1326,8 @@ static int FDECL1(pvd_write, FILE *, outfile)
* This will break in the year 2000, I supose, but there is no good way
* to get the top two digits of the year.
*/
- sprintf(iso_time, "%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d00", 1900 + local.tm_year,
+ snprintf(iso_time, sizeof iso_time, "%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d00",
+ 1900 + local.tm_year,
local.tm_mon+1, local.tm_mday,
local.tm_hour, local.tm_min, local.tm_sec);
@@ -1512,7 +1514,7 @@ static int file_gen()
/* allocate memory for the libhfs/mkisofs extra info */
hce = (hce_mem *)e_malloc(sizeof(hce_mem));
- hce->error = (char *)e_malloc(1024);
+ hce->error = (char *)e_malloc(ERROR_SIZE);
/* mark as unallocated for use later */
hce->hfs_ce = hce->hfs_hdr = hce->hfs_map = 0;