diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2012-07-08 17:01:13 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2012-07-08 17:01:13 -0700 |
commit | fb4e0599a5ddaef9eee726f786b9edef4943432b (patch) | |
tree | 6d73ba36fb267af597838d85cae86ca8188014f1 /examples | |
parent | aef4174dd2b95029e29e004f4d4cae684d396033 (diff) | |
download | zlib-fb4e0599a5ddaef9eee726f786b9edef4943432b.tar.gz zlib-fb4e0599a5ddaef9eee726f786b9edef4943432b.tar.bz2 zlib-fb4e0599a5ddaef9eee726f786b9edef4943432b.zip |
Fix argument checks in gzlog_compress() and gzlog_write().
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gzlog.c | 10 | ||||
-rw-r--r-- | examples/gzlog.h | 5 |
2 files changed, 8 insertions, 7 deletions
diff --git a/examples/gzlog.c b/examples/gzlog.c index d70aaca..de32058 100644 --- a/examples/gzlog.c +++ b/examples/gzlog.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * gzlog.c | 2 | * gzlog.c |
3 | * Copyright (C) 2004, 2008 Mark Adler, all rights reserved | 3 | * Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved |
4 | * For conditions of distribution and use, see copyright notice in gzlog.h | 4 | * For conditions of distribution and use, see copyright notice in gzlog.h |
5 | * version 2.0, 25 Apr 2008 | 5 | * version 2.1, 8 Jul 2012 |
6 | */ | 6 | */ |
7 | 7 | ||
8 | /* | 8 | /* |
@@ -913,7 +913,7 @@ int gzlog_compress(gzlog *logd) | |||
913 | struct log *log = logd; | 913 | struct log *log = logd; |
914 | 914 | ||
915 | /* check arguments */ | 915 | /* check arguments */ |
916 | if (log == NULL || strcmp(log->id, LOGID) || len < 0) | 916 | if (log == NULL || strcmp(log->id, LOGID)) |
917 | return -3; | 917 | return -3; |
918 | 918 | ||
919 | /* see if we lost the lock -- if so get it again and reload the extra | 919 | /* see if we lost the lock -- if so get it again and reload the extra |
@@ -997,9 +997,9 @@ int gzlog_write(gzlog *logd, void *data, size_t len) | |||
997 | struct log *log = logd; | 997 | struct log *log = logd; |
998 | 998 | ||
999 | /* check arguments */ | 999 | /* check arguments */ |
1000 | if (log == NULL || strcmp(log->id, LOGID) || len < 0) | 1000 | if (log == NULL || strcmp(log->id, LOGID)) |
1001 | return -3; | 1001 | return -3; |
1002 | if (data == NULL || len == 0) | 1002 | if (data == NULL || len <= 0) |
1003 | return 0; | 1003 | return 0; |
1004 | 1004 | ||
1005 | /* see if we lost the lock -- if so get it again and reload the extra | 1005 | /* see if we lost the lock -- if so get it again and reload the extra |
diff --git a/examples/gzlog.h b/examples/gzlog.h index c461426..4e093bc 100644 --- a/examples/gzlog.h +++ b/examples/gzlog.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* gzlog.h | 1 | /* gzlog.h |
2 | Copyright (C) 2004, 2008 Mark Adler, all rights reserved | 2 | Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved |
3 | version 2.0, 25 Apr 2008 | 3 | version 2.1, 8 Jul 2012 |
4 | 4 | ||
5 | This software is provided 'as-is', without any express or implied | 5 | This software is provided 'as-is', without any express or implied |
6 | warranty. In no event will the author be held liable for any damages | 6 | warranty. In no event will the author be held liable for any damages |
@@ -27,6 +27,7 @@ | |||
27 | Interface changed slightly in that now path is a prefix | 27 | Interface changed slightly in that now path is a prefix |
28 | Compression now occurs as needed during gzlog_write() | 28 | Compression now occurs as needed during gzlog_write() |
29 | gzlog_write() now always leaves the log file as valid gzip | 29 | gzlog_write() now always leaves the log file as valid gzip |
30 | 2.1 8 Jul 2012 Fix argument checks in gzlog_compress() and gzlog_write() | ||
30 | */ | 31 | */ |
31 | 32 | ||
32 | /* | 33 | /* |