From f8d09cb43d957fad72b19df42cad28a017e55ed5 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Thu, 22 Jan 2009 11:19:21 +0100 Subject: [PATCH] lpr: don't rely on dirs having st_size > 0 getq determines the initial size of its queue array based on the st_size of the queue directory. If the queue directory is on a HAMMER file system, this size will be reported as 0. However the following array growing logic just doubles the array size, thus always staying at 0. Use a sensible minimum array size of 20 items (~ 512/24). Reported-and-fix-by: Patrick Georgi --- usr.sbin/lpr/common_source/common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c index 4b1863793b..62469749e0 100644 --- a/usr.sbin/lpr/common_source/common.c +++ b/usr.sbin/lpr/common_source/common.c @@ -124,8 +124,11 @@ getq(const struct printer *pp, struct jobqueue *(*namelist[])) /* * Estimate the array size by taking the size of the directory file * and dividing it by a multiple of the minimum size entry. + * + * However some file systems do report a directory size == 0 (HAMMER + * for instance). Use a sensible minimum size for the array. */ - arraysz = (stbuf.st_size / 24); + arraysz = MAX(20, (stbuf.st_size / 24)); queue = (struct jobqueue **)malloc(arraysz * sizeof(struct jobqueue *)); if (queue == NULL) goto errdone; -- 2.11.4.GIT