From ba85f6c77981db6f3bfba1d40a1d211a0c6c26ce Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 21 Dec 2000 07:47:53 +0000 Subject: 2000-12-20 Roland McGrath * zero.c (zero_open): Check for END being null after strtoul call. If character following number (*END) is b, multiply size by 512; k or K, by 1024; m or M by 1024*1024; g or G by 1024*1024*1024. --- libstore/zero.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/libstore/zero.c b/libstore/zero.c index 55f84a2c..f0a23276 100644 --- a/libstore/zero.c +++ b/libstore/zero.c @@ -1,7 +1,7 @@ /* Zero store backend - Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc. - Written by Miles Bader + Copyright (C) 1995,96,97,99,2000 Free Software Foundation, Inc. + Written by Miles Bader This file is part of the GNU Hurd. The GNU Hurd is free software; you can redistribute it and/or @@ -118,8 +118,26 @@ zero_open (const char *name, int flags, { char *end; off_t size = strtoul (name, &end, 0); - if (end == name) + if (end == name || end == NULL) return EINVAL; + switch (*end) + { + case 'b': + size *= 512; + break; + case 'k': + case 'K': + size *= 1024; + break; + case 'm': + case 'M': + size *= 1024 * 1024; + break; + case 'g': + case 'G': + size *= 1024 * 1024 * 1024; + break; + } return store_zero_create (size, flags, store); } else -- cgit v1.2.3