Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 62618 | Differences between
and this patch

Collapse All | Expand All

(-)lha-114i.orig/src/lha_macro.h (-1 / +1 lines)
Lines 53-59 Link Here
53
#define SEEK_SET		0
53
#define SEEK_SET		0
54
#define SEEK_CUR		1
54
#define SEEK_CUR		1
55
#define SEEK_END		2
55
#define SEEK_END		2
56
#endif	/* SEEK_SET
56
#endif	/* SEEK_SET */
57
57
58
58
59
/* non-integral functions */
59
/* non-integral functions */
(-)lha-114i.orig/src/lharc.c (-6 / +21 lines)
Lines 830-838 find_files(name, v_filec, v_filev) Link Here
830
	DIRENTRY       *dp;
830
	DIRENTRY       *dp;
831
	struct stat     tmp_stbuf, arc_stbuf, fil_stbuf;
831
	struct stat     tmp_stbuf, arc_stbuf, fil_stbuf;
832
832
833
	strcpy(newname, name);
833
	strncpy(newname, name, sizeof(newname));
834
	newname[sizeof(newname)-1] = 0;
834
	len = strlen(name);
835
	len = strlen(name);
835
	if (len > 0 && newname[len - 1] != '/')
836
	if (len > 0 && newname[len - 1] != '/' && len < (sizeof(newname)-1))
836
		newname[len++] = '/';
837
		newname[len++] = '/';
837
838
838
	dirp = opendir(name);
839
	dirp = opendir(name);
Lines 846-851 find_files(name, v_filec, v_filev) Link Here
846
847
847
	for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
848
	for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
848
		n = NAMLEN(dp);
849
		n = NAMLEN(dp);
850
		if (len >= (sizeof(newname)-1) ||
851
				(len+n) >= (sizeof(newname)-1) ||
852
					 n  <= 0                   ||
853
				(len+n) <= 0)
854
			break;
849
		strncpy(newname + len, dp->d_name, n);
855
		strncpy(newname + len, dp->d_name, n);
850
		newname[len + n] = '\0';
856
		newname[len + n] = '\0';
851
		if (GETSTAT(newname, &fil_stbuf) < 0)
857
		if (GETSTAT(newname, &fil_stbuf) < 0)
Lines 903-909 build_temporary_name() Link Here
903
		strcpy(temporary_name, TMP_FILENAME_TEMPLATE);
909
		strcpy(temporary_name, TMP_FILENAME_TEMPLATE);
904
	}
910
	}
905
	else {
911
	else {
906
		sprintf(temporary_name, "%s/lhXXXXXX", extract_directory);
912
		snprintf(temporary_name, sizeof(temporary_name),
913
			"%s/lhXXXXXX", extract_directory);
907
	}
914
	}
908
#ifdef MKSTEMP
915
#ifdef MKSTEMP
909
	mkstemp(temporary_name);
916
	mkstemp(temporary_name);
Lines 913-922 build_temporary_name() Link Here
913
#else
920
#else
914
	char           *p, *s;
921
	char           *p, *s;
915
922
916
	strcpy(temporary_name, archive_name);
923
	strncpy(temporary_name, archive_name, sizeof(temporary_name));
924
	temporary_name[sizeof(temporary_name)-1] = 0;
917
	for (p = temporary_name, s = (char *) 0; *p; p++)
925
	for (p = temporary_name, s = (char *) 0; *p; p++)
918
		if (*p == '/')
926
		if (*p == '/')
919
			s = p;
927
			s = p;
928
929
	if( sizeof(temporary_name) - ((size_t) (s-temporary_name)) - 1
930
		<= strlen("lhXXXXXX"))
931
			exit(-1);
932
920
	strcpy((s ? s + 1 : temporary_name), "lhXXXXXX");
933
	strcpy((s ? s + 1 : temporary_name), "lhXXXXXX");
921
#ifdef MKSTEMP
934
#ifdef MKSTEMP
922
	mkstemp(temporary_name);
935
	mkstemp(temporary_name);
Lines 1052-1058 open_old_archive() Link Here
1052
1065
1053
	if (open_old_archive_1(archive_name, &fp))
1066
	if (open_old_archive_1(archive_name, &fp))
1054
		return fp;
1067
		return fp;
1055
	sprintf(expanded_archive_name, "%s.lzh", archive_name);
1068
	snprintf(expanded_archive_name, sizeof(expanded_archive_name),
1069
		"%s.lzh", archive_name);
1056
	if (open_old_archive_1(expanded_archive_name, &fp)) {
1070
	if (open_old_archive_1(expanded_archive_name, &fp)) {
1057
		archive_name = expanded_archive_name;
1071
		archive_name = expanded_archive_name;
1058
		return fp;
1072
		return fp;
Lines 1061-1067 open_old_archive() Link Here
1061
	 * if ( (errno&0xffff)!=E_PNNF ) { archive_name =
1075
	 * if ( (errno&0xffff)!=E_PNNF ) { archive_name =
1062
	 * expanded_archive_name; return NULL; }
1076
	 * expanded_archive_name; return NULL; }
1063
	 */
1077
	 */
1064
	sprintf(expanded_archive_name, "%s.lzs", archive_name);
1078
	snprintf(expanded_archive_name, sizeof(expanded_archive_name),
1079
		"%s.lzs", archive_name);
1065
	if (open_old_archive_1(expanded_archive_name, &fp)) {
1080
	if (open_old_archive_1(expanded_archive_name, &fp)) {
1066
		archive_name = expanded_archive_name;
1081
		archive_name = expanded_archive_name;
1067
		return fp;
1082
		return fp;
(-)lha-114i.orig/src/lhext.c (-7 / +12 lines)
Lines 82-88 make_parent_path(name) Link Here
82
	register char  *p;
82
	register char  *p;
83
83
84
	/* make parent directory name into PATH for recursive call */
84
	/* make parent directory name into PATH for recursive call */
85
	strcpy(path, name);
85
	memset(path, 0, sizeof(path));
86
	strncpy(path, name, sizeof(path)-1);
86
	for (p = path + strlen(path); p > path; p--)
87
	for (p = path + strlen(path); p > path; p--)
87
		if (p[-1] == '/') {
88
		if (p[-1] == '/') {
88
			*--p = '\0';
89
			*--p = '\0';
Lines 212-220 extract_one(afp, hdr) Link Here
212
	}
213
	}
213
214
214
	if (extract_directory)
215
	if (extract_directory)
215
		sprintf(name, "%s/%s", extract_directory, q);
216
		snprintf(name, sizeof(name), "%s/%s", extract_directory, q);
216
	else
217
	else {
217
		strcpy(name, q);
218
		strncpy(name, q, sizeof(name));
219
		name[sizeof(name) - 1] = '\0';
220
	}
218
221
219
222
220
	/* LZHDIRS_METHOD�����ĥإå��������å����� */
223
	/* LZHDIRS_METHOD�����ĥإå��������å����� */
Lines 335-341 extract_one(afp, hdr) Link Here
335
			if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) {
338
			if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) == UNIX_FILE_SYMLINK) {
336
				char            buf[256], *bb1, *bb2;
339
				char            buf[256], *bb1, *bb2;
337
				int             l_code;
340
				int             l_code;
338
				strcpy(buf, name);
341
				strncpy(buf, name, sizeof(buf));
342
				buf[sizeof(buf)-1] = 0;
339
				bb1 = strtok(buf, "|");
343
				bb1 = strtok(buf, "|");
340
				bb2 = strtok(NULL, "|");
344
				bb2 = strtok(NULL, "|");
341
345
Lines 365-373 extract_one(afp, hdr) Link Here
365
				if (quiet != TRUE) {
369
				if (quiet != TRUE) {
366
					printf("Symbolic Link %s -> %s\n", bb1, bb2);
370
					printf("Symbolic Link %s -> %s\n", bb1, bb2);
367
				}
371
				}
368
				strcpy(name, bb1);	/* Symbolic's name set */
372
				strncpy(name, bb1, 255);	/* Symbolic's name set */
373
				name[255] = 0;
369
#else
374
#else
370
				sprintf(buf, "%s -> %s", bb1, bb2);
375
				sprintf(buf, sizeof(buf), "%s -> %s", bb1, bb2);
371
				warning("Can't make Symbolic Link", buf);
376
				warning("Can't make Symbolic Link", buf);
372
				return;
377
				return;
373
#endif
378
#endif
(-)lha-114i.orig/src/lhlist.c (-1 / +2 lines)
Lines 250-256 list_one(hdr) Link Here
250
			printf(" %s", hdr->name);
250
			printf(" %s", hdr->name);
251
		else {
251
		else {
252
			char            buf[256], *b1, *b2;
252
			char            buf[256], *b1, *b2;
253
			strcpy(buf, hdr->name);
253
			strncpy(buf, hdr->name, sizeof(buf));
254
			buf[sizeof(buf)-1] = 0;
254
			b1 = strtok(buf, "|");
255
			b1 = strtok(buf, "|");
255
			b2 = strtok(NULL, "|");
256
			b2 = strtok(NULL, "|");
256
			printf(" %s -> %s", b1, b2);
257
			printf(" %s -> %s", b1, b2);
(-)lha-114i.orig/src/util.c (-13 / +19 lines)
Lines 276-296 rmdir(path) Link Here
276
	char           *path;
276
	char           *path;
277
{
277
{
278
	int             stat, rtn = 0;
278
	int             stat, rtn = 0;
279
	char           *cmdname;
279
	pid_t           child;
280
	if ((cmdname = (char *) malloc(strlen(RMDIRPATH) + 1 + strlen(path) + 1))
280
281
	    == 0)
281
282
	/* XXX thomas: shell meta chars in path could exec commands */
283
	/* therefore we should avoid using system() */
284
	if ((child = fork()) < 0)
285
		return (-1);    /* fork error */
286
	else if (child) {       /* parent process */
287
		while (child != wait(&stat))    /* ignore signals */
288
			continue;
289
	}
290
	else {                  /* child process */
291
		execl(RMDIRPATH, "rmdir", path, (char *) 0);
292
		/* never come here except execl is error */
282
		return (-1);
293
		return (-1);
283
	strcpy(cmdname, RMDIRPATH);
284
	*(cmdname + strlen(RMDIRPATH)) = ' ';
285
	strcpy(cmdname + strlen(RMDIRPATH) + 1, path);
286
	if ((stat = system(cmdname)) < 0)
287
		rtn = -1;	/* fork or exec error */
288
	else if (stat) {	/* RMDIR command error */
289
		errno = EIO;
290
		rtn = -1;
291
	}
294
	}
292
	free(cmdname);
295
	if (stat != 0) {
293
	return (rtn);
296
		errno = EIO;    /* cannot get error num. */
297
		return (-1);
298
	}
299
	return (0);
294
}
300
}
295
301
296
/* ------------------------------------------------------------------------ */
302
/* ------------------------------------------------------------------------ */

Return to bug 62618