View | Details | Raw Unified | Return to bug 250489
Collapse All | Expand All

(-)admin.c (-4 / +9 lines)
Lines 246-257 Link Here
246
		struct cvs_file *ocf;
246
		struct cvs_file *ocf;
247
		struct rcs_access *acp;
247
		struct rcs_access *acp;
248
		int ofd;
248
		int ofd;
249
		char *d, *f, fpath[PATH_MAX], repo[PATH_MAX];
249
		char *d, dbuf[PATH_MAX], *f, fbuf[PATH_MAX];
250
		char fpath[PATH_MAX], repo[PATH_MAX];
250
251
251
252
		if (strlcpy(fbuf, oldfilename, sizeof(fbuf)) >= sizeof(fbuf))
252
		if ((f = basename(oldfilename)) == NULL)
253
			fatal("cvs_admin_local: truncation");
254
		if ((f = basename(fbuf)) == NULL)
253
			fatal("cvs_admin_local: basename failed");
255
			fatal("cvs_admin_local: basename failed");
254
		if ((d = dirname(oldfilename)) == NULL)
256
257
		if (strlcpy(dbuf, oldfilename, sizeof(dbuf)) >= sizeof(dbuf))
258
			fatal("cvs_admin_local: truncation");
259
		if ((d = dirname(dbuf)) == NULL)
255
			fatal("cvs_admin_local: dirname failed");
260
			fatal("cvs_admin_local: dirname failed");
256
261
257
		cvs_get_repository_path(d, repo, PATH_MAX);
262
		cvs_get_repository_path(d, repo, PATH_MAX);
(-)checkout.c (-8 / +24 lines)
Lines 239-245 Link Here
239
	struct module_checkout *mc;
239
	struct module_checkout *mc;
240
	struct cvs_ignpat *ip;
240
	struct cvs_ignpat *ip;
241
	struct cvs_filelist *fl, *nxt;
241
	struct cvs_filelist *fl, *nxt;
242
	char repo[PATH_MAX], fpath[PATH_MAX], *f[1];
242
	char repo[PATH_MAX], fpath[PATH_MAX], path[PATH_MAX], *f[1];
243
243
244
	build_dirs = print_stdout ? 0 : 1;
244
	build_dirs = print_stdout ? 0 : 1;
245
245
Lines 329-342 Link Here
329
				cr.flags = flags;
329
				cr.flags = flags;
330
330
331
				if (!(mc->mc_flags & MODULE_ALIAS)) {
331
				if (!(mc->mc_flags & MODULE_ALIAS)) {
332
					if (strlcpy(path, fl->file_path,
333
					    sizeof(path)) >= sizeof(path))
334
						fatal("%s: truncation",
335
						    __func__);
332
					module_repo_root =
336
					module_repo_root =
333
					    xstrdup(dirname(fl->file_path));
337
					    xstrdup(dirname(path));
334
					d = wdir;
338
					d = wdir;
339
					if (strlcpy(path, fl->file_path,
340
					    sizeof(path)) >= sizeof(path))
341
						fatal("%s: truncation",
342
						    __func__);
335
					(void)xsnprintf(fpath, sizeof(fpath),
343
					(void)xsnprintf(fpath, sizeof(fpath),
336
					    "%s/%s", d,
344
					    "%s/%s", d, basename(path));
337
					    basename(fl->file_path));
338
				} else {
345
				} else {
339
					d = dirname(wdir);
346
					if (strlcpy(path, wdir,
347
					    sizeof(path)) >= sizeof(path))
348
						fatal("%s: truncation",
349
						    __func__);
350
					d = dirname(path);
340
					strlcpy(fpath, fl->file_path,
351
					strlcpy(fpath, fl->file_path,
341
					    sizeof(fpath));
352
					    sizeof(fpath));
342
				}
353
				}
Lines 387-393 Link Here
387
static int
398
static int
388
checkout_classify(const char *repo, const char *arg)
399
checkout_classify(const char *repo, const char *arg)
389
{
400
{
390
	char *d, *f, fpath[PATH_MAX];
401
	char *d, dbuf[PATH_MAX], *f, fbuf[PATH_MAX], fpath[PATH_MAX];
391
	struct stat sb;
402
	struct stat sb;
392
403
393
	if (stat(repo, &sb) == 0) {
404
	if (stat(repo, &sb) == 0) {
Lines 395-402 Link Here
395
			return CVS_DIR;
406
			return CVS_DIR;
396
	}
407
	}
397
408
398
	d = dirname(repo);
409
	if (strlcpy(dbuf, repo, sizeof(dbuf)) >= sizeof(dbuf))
399
	f = basename(repo);
410
		fatal("checkout_classify: truncation");
411
	d = dirname(dbuf);
412
413
	if (strlcpy(fbuf, repo, sizeof(fbuf)) >= sizeof(fbuf))
414
		fatal("checkout_classify: truncation");
415
	f = basename(fbuf);
400
416
401
	(void)xsnprintf(fpath, sizeof(fpath), "%s/%s%s", d, f, RCS_FILE_EXT);
417
	(void)xsnprintf(fpath, sizeof(fpath), "%s/%s%s", d, f, RCS_FILE_EXT);
402
	if (stat(fpath, &sb) == 0) {
418
	if (stat(fpath, &sb) == 0) {
(-)client.c (-4 / +11 lines)
Lines 157-162 Link Here
157
{
157
{
158
	CVSENTRIES *entlist;
158
	CVSENTRIES *entlist;
159
	char *entry, *parent, *base, *p;
159
	char *entry, *parent, *base, *p;
160
	char basebuf[PATH_MAX], parentbuf[PATH_MAX];
160
161
161
	STRIP_SLASH(data);
162
	STRIP_SLASH(data);
162
163
Lines 174-183 Link Here
174
	if (cvs_cmdop == CVS_OP_EXPORT)
175
	if (cvs_cmdop == CVS_OP_EXPORT)
175
		return;
176
		return;
176
177
177
	if ((base = basename(data)) == NULL)
178
	if (strlcpy(basebuf, data, sizeof(basebuf)) >= sizeof(basebuf))
179
		fatal("client_check_directory: truncation");
180
	if ((base = basename(basebuf)) == NULL)
178
		fatal("client_check_directory: overflow");
181
		fatal("client_check_directory: overflow");
179
182
180
	if ((parent = dirname(data)) == NULL)
183
	if (strlcpy(parentbuf, data, sizeof(parentbuf)) >= sizeof(parentbuf))
184
		fatal("client_check_directory: truncation");
185
	if ((parent = dirname(parentbuf)) == NULL)
181
		fatal("client_check_directory: overflow");
186
		fatal("client_check_directory: overflow");
182
187
183
	if (!strcmp(parent, "."))
188
	if (!strcmp(parent, "."))
Lines 798-804 Link Here
798
	struct timeval tv[2];
803
	struct timeval tv[2];
799
	struct tm datetm;
804
	struct tm datetm;
800
	char timebuf[CVS_TIME_BUFSZ], *repo, *rpath, *entry, *mode;
805
	char timebuf[CVS_TIME_BUFSZ], *repo, *rpath, *entry, *mode;
801
	char *len, *fpath, *wdir;
806
	char *len, *fpath, *wdir, wdirbuf[PATH_MAX];
802
807
803
	if (data == NULL)
808
	if (data == NULL)
804
		fatal("Missing argument for Merged");
809
		fatal("Missing argument for Merged");
Lines 819-825 Link Here
819
		fatal("received a repository path that is too short");
824
		fatal("received a repository path that is too short");
820
825
821
	fpath = rpath + strlen(repo) + 1;
826
	fpath = rpath + strlen(repo) + 1;
822
	if ((wdir = dirname(fpath)) == NULL)
827
	if (strlcpy(wdirbuf, fpath, sizeof(wdirbuf)) >= sizeof(wdirbuf))
828
		fatal("cvs_client_merged: truncation");
829
	if ((wdir = dirname(wdirbuf)) == NULL)
823
		fatal("cvs_client_merged: dirname: %s", strerror(errno));
830
		fatal("cvs_client_merged: dirname: %s", strerror(errno));
824
	free(repo);
831
	free(repo);
825
832
(-)file.c (-3 / +9 lines)
Lines 266-272 Link Here
266
	struct stat st;
266
	struct stat st;
267
	struct cvs_file *cf;
267
	struct cvs_file *cf;
268
	struct cvs_filelist *l, *nxt;
268
	struct cvs_filelist *l, *nxt;
269
	char *d, *f, repo[PATH_MAX], fpath[PATH_MAX];
269
	char *d, dbuf[PATH_MAX], *f, fbuf[PATH_MAX];
270
	char repo[PATH_MAX], fpath[PATH_MAX];
270
271
271
	for (l = RB_MIN(cvs_flisthead, fl); l != NULL; l = nxt) {
272
	for (l = RB_MIN(cvs_flisthead, fl); l != NULL; l = nxt) {
272
		if (cvs_quit)
273
		if (cvs_quit)
Lines 275-283 Link Here
275
		cvs_log(LP_TRACE, "cvs_file_walklist: element '%s'",
276
		cvs_log(LP_TRACE, "cvs_file_walklist: element '%s'",
276
		    l->file_path);
277
		    l->file_path);
277
278
278
		if ((f = basename(l->file_path)) == NULL)
279
		if (strlcpy(fbuf, l->file_path, sizeof(fbuf)) >= sizeof(fbuf))
280
			fatal("cvs_file_walklist: truncation");
281
		if ((f = basename(fbuf)) == NULL)
279
			fatal("cvs_file_walklist: basename failed");
282
			fatal("cvs_file_walklist: basename failed");
280
		if ((d = dirname(l->file_path)) == NULL)
283
284
		if (strlcpy(dbuf, l->file_path, sizeof(dbuf)) >= sizeof(dbuf))
285
			fatal("cvs_file_walklist: truncation");
286
		if ((d = dirname(dbuf)) == NULL)
281
			fatal("cvs_file_walklist: dirname failed");
287
			fatal("cvs_file_walklist: dirname failed");
282
288
283
		type = l->type;
289
		type = l->type;
(-)logmsg.c (-12 / +31 lines)
Lines 100-105 Link Here
100
	struct cvs_filelist *cf;
100
	struct cvs_filelist *cf;
101
	struct stat st1, st2;
101
	struct stat st1, st2;
102
	char *fpath, *logmsg, repo[PATH_MAX];
102
	char *fpath, *logmsg, repo[PATH_MAX];
103
	char *f, path[PATH_MAX];
103
	struct stat st;
104
	struct stat st;
104
	struct trigger_list *line_list;
105
	struct trigger_list *line_list;
105
	struct trigger_line *line;
106
	struct trigger_line *line;
Lines 165-192 Link Here
165
166
166
	if (added != NULL && !RB_EMPTY(added)) {
167
	if (added != NULL && !RB_EMPTY(added)) {
167
		fprintf(fp, "%s Added Files:", CVS_LOGMSG_PREFIX);
168
		fprintf(fp, "%s Added Files:", CVS_LOGMSG_PREFIX);
168
		RB_FOREACH(cf, cvs_flisthead, added)
169
		RB_FOREACH(cf, cvs_flisthead, added) {
169
			fprintf(fp, "\n%s\t%s", CVS_LOGMSG_PREFIX,
170
			f = cf->file_path;
170
			    dir != NULL ? basename(cf->file_path) :
171
			if (dir != NULL) {
171
			    cf->file_path);
172
				if (strlcpy(path, f, sizeof(path)) >=
173
				    sizeof(path))
174
					fatal("cvs_logmsg_create: truncation");
175
				f = basename(path);
176
			}
177
			fprintf(fp, "\n%s\t%s", CVS_LOGMSG_PREFIX, f);
178
		}
172
		fputs("\n", fp);
179
		fputs("\n", fp);
173
	}
180
	}
174
181
175
	if (removed != NULL && !RB_EMPTY(removed)) {
182
	if (removed != NULL && !RB_EMPTY(removed)) {
176
		fprintf(fp, "%s Removed Files:", CVS_LOGMSG_PREFIX);
183
		fprintf(fp, "%s Removed Files:", CVS_LOGMSG_PREFIX);
177
		RB_FOREACH(cf, cvs_flisthead, removed)
184
		RB_FOREACH(cf, cvs_flisthead, removed) {
178
			fprintf(fp, "\n%s\t%s", CVS_LOGMSG_PREFIX,
185
			f = cf->file_path;
179
			    dir != NULL ? basename(cf->file_path) :
186
			if (dir != NULL) {
180
			    cf->file_path);
187
				if (strlcpy(path, f, sizeof(path)) >=
188
				    sizeof(path))
189
					fatal("cvs_logmsg_create: truncation");
190
				f = basename(path);
191
			}
192
			fprintf(fp, "\n%s\t%s", CVS_LOGMSG_PREFIX, f);
193
		}
181
		fputs("\n", fp);
194
		fputs("\n", fp);
182
	}
195
	}
183
196
184
	if (modified != NULL && !RB_EMPTY(modified)) {
197
	if (modified != NULL && !RB_EMPTY(modified)) {
185
		fprintf(fp, "%s Modified Files:", CVS_LOGMSG_PREFIX);
198
		fprintf(fp, "%s Modified Files:", CVS_LOGMSG_PREFIX);
186
		RB_FOREACH(cf, cvs_flisthead, modified)
199
		RB_FOREACH(cf, cvs_flisthead, modified) {
187
			fprintf(fp, "\n%s\t%s", CVS_LOGMSG_PREFIX,
200
			f = cf->file_path;
188
			    dir != NULL ? basename(cf->file_path) :
201
			if (dir != NULL) {
189
			    cf->file_path);
202
				if (strlcpy(path, f, sizeof(path)) >=
203
				    sizeof(path))
204
					fatal("cvs_logmsg_create: truncation");
205
				f = basename(path);
206
			}
207
			fprintf(fp, "\n%s\t%s", CVS_LOGMSG_PREFIX, f);
208
		}
190
		fputs("\n", fp);
209
		fputs("\n", fp);
191
	}
210
	}
192
211
(-)rcs.c (-4 / +8 lines)
Lines 2190-2197 Link Here
2190
	int kwtype;
2190
	int kwtype;
2191
	u_int j, found;
2191
	u_int j, found;
2192
	const u_char *c, *start, *fin, *end;
2192
	const u_char *c, *start, *fin, *end;
2193
	char *kwstr;
2193
	char *kwstr, *rcsfile_basename;
2194
	char expbuf[256], buf[256];
2194
	char expbuf[256], buf[256], path[PATH_MAX];
2195
	size_t clen, kwlen, len, tlen;
2195
	size_t clen, kwlen, len, tlen;
2196
2196
2197
	kwtype = 0;
2197
	kwtype = 0;
Lines 2209-2214 Link Here
2209
	/* Final character in buffer. */
2209
	/* Final character in buffer. */
2210
	fin = c + len - 1;
2210
	fin = c + len - 1;
2211
2211
2212
	if (strlcpy(path, rcsfile, sizeof(path)) >= sizeof(path))
2213
		fatal("rcs_kwexp_line: truncation");
2214
	rcsfile_basename = basename(path);
2215
2212
	/*
2216
	/*
2213
	 * Keyword formats:
2217
	 * Keyword formats:
2214
	 * $Keyword$
2218
	 * $Keyword$
Lines 2307-2313 Link Here
2307
		if (mode & RCS_KWEXP_VAL) {
2311
		if (mode & RCS_KWEXP_VAL) {
2308
			if (kwtype & RCS_KW_RCSFILE) {
2312
			if (kwtype & RCS_KW_RCSFILE) {
2309
				if (!(kwtype & RCS_KW_FULLPATH))
2313
				if (!(kwtype & RCS_KW_FULLPATH))
2310
					(void)strlcat(expbuf, basename(rcsfile),
2314
					(void)strlcat(expbuf, rcsfile_basename,
2311
					    sizeof(expbuf));
2315
					    sizeof(expbuf));
2312
				else
2316
				else
2313
					(void)strlcat(expbuf, rcsfile,
2317
					(void)strlcat(expbuf, rcsfile,
Lines 2383-2389 Link Here
2383
				/* Log line */
2387
				/* Log line */
2384
				if (!(kwtype & RCS_KW_FULLPATH))
2388
				if (!(kwtype & RCS_KW_FULLPATH))
2385
					(void)strlcat(expbuf,
2389
					(void)strlcat(expbuf,
2386
					    basename(rcsfile), sizeof(expbuf));
2390
					    rcsfile_basename, sizeof(expbuf));
2387
				else
2391
				else
2388
					(void)strlcat(expbuf, rcsfile,
2392
					(void)strlcat(expbuf, rcsfile,
2389
					    sizeof(expbuf));
2393
					    sizeof(expbuf));
(-)server.c (-2 / +7 lines)
Lines 324-329 Link Here
324
{
324
{
325
	CVSENTRIES *entlist;
325
	CVSENTRIES *entlist;
326
	char *dir, *repo, *parent, *entry, *dirn, *p;
326
	char *dir, *repo, *parent, *entry, *dirn, *p;
327
	char parentbuf[PATH_MAX], dirnbuf[PATH_MAX];
327
328
328
	if (current_cvsroot == NULL)
329
	if (current_cvsroot == NULL)
329
		fatal("No Root specified for Directory");
330
		fatal("No Root specified for Directory");
Lines 350-359 Link Here
350
351
351
	cvs_mkpath(p, NULL);
352
	cvs_mkpath(p, NULL);
352
353
353
	if ((dirn = basename(p)) == NULL)
354
	if (strlcpy(dirnbuf, p, sizeof(dirnbuf)) >= sizeof(dirnbuf))
355
		fatal("cvs_server_directory: truncation");
356
	if ((dirn = basename(dirnbuf)) == NULL)
354
		fatal("cvs_server_directory: %s", strerror(errno));
357
		fatal("cvs_server_directory: %s", strerror(errno));
355
358
356
	if ((parent = dirname(p)) == NULL)
359
	if (strlcpy(parentbuf, p, sizeof(parentbuf)) >= sizeof(parentbuf))
360
		fatal("cvs_server_directory: truncation");
361
	if ((parent = dirname(parentbuf)) == NULL)
357
		fatal("cvs_server_directory: %s", strerror(errno));
362
		fatal("cvs_server_directory: %s", strerror(errno));
358
363
359
	if (strcmp(parent, ".")) {
364
	if (strcmp(parent, ".")) {

Return to bug 250489