-
Notifications
You must be signed in to change notification settings - Fork 844
Clam 2102 cl cvd unpack #690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3710610
libclamav API: Add cl_cvdunpack() function
val-ms 887d8b4
Freshclam, Sigtool: use public CVD unpack API
val-ms 5d97eaf
Tests: unit tests for cl_load(), cl_cvdverify(), cl_cvdunpack()
val-ms e0f5bbd
Add example program to test cl_cvdunpack & test
val-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /* | ||
| * Compilation: gcc -Wall ex1.c -o ex1 -lclamav | ||
| * | ||
| * Copyright (C) 2013-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved. | ||
| * Copyright (C) 2007-2013 Sourcefire, Inc. | ||
| * Author: Tomasz Kojm <[email protected]> | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 2 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
| * MA 02110-1301, USA. | ||
| */ | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #ifndef _WIN32 | ||
| #include <unistd.h> | ||
| #endif | ||
| #include <sys/types.h> | ||
| #include <sys/stat.h> | ||
| #include <fcntl.h> | ||
| #include <clamav.h> | ||
|
|
||
| #ifndef O_BINARY | ||
| #define O_BINARY 0 | ||
| #endif | ||
|
|
||
| /* | ||
| * Exit codes: 0 is success. See `cl_error_t` enum from clamav.h. | ||
| */ | ||
| int main(int argc, char **argv) | ||
| { | ||
| int fd; | ||
| cl_error_t ret; | ||
|
|
||
| const char *filename; | ||
| const char *destination_directory; | ||
| bool dont_verify = false; | ||
|
|
||
| char dest_buff[1024]; | ||
|
|
||
| unsigned long int size = 0; | ||
| unsigned int sigs = 0; | ||
| long double mb; | ||
| const char *virname; | ||
| struct cl_engine *engine; | ||
| struct cl_scan_options options; | ||
|
|
||
| switch (argc) { | ||
| case 2: | ||
| filename = argv[1]; | ||
| destination_directory = "."; | ||
| break; | ||
| case 3: | ||
| filename = argv[1]; | ||
| destination_directory = argv[2]; | ||
| break; | ||
| case 4: | ||
| if (strcmp(argv[1], "--no-verify") == 0) { | ||
| filename = argv[2]; | ||
| destination_directory = argv[3]; | ||
| dont_verify = true; | ||
| } else { | ||
| printf("Usage: %s [--no-verify] file [destination_directory]\n", argv[0]); | ||
| return CL_EARG; | ||
| } | ||
| break; | ||
| default: | ||
| printf("Usage: %s [--no-verify] file [destination_directory]\n", argv[0]); | ||
| return CL_EARG; | ||
| } | ||
|
|
||
| ret = cl_cvdunpack(filename, destination_directory, dont_verify); | ||
| if (ret != CL_SUCCESS) { | ||
| printf("ERROR: %s\n", cl_strerror(ret)); | ||
| } | ||
|
|
||
| return (int)ret; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this cli_strerror call use err[128] when the others do not? This is not a static function or anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our
cli_strerroris a wrapper for the poorly standardizedstrerrorsystem function, not to be confused withcl_strerror, which is the clamav API for converting the clam error enum to a message.The
err[128]approach is something I copypasted from elsewhere in the code. Such as: https://github.com/Cisco-Talos/clamav/blob/main/libclamav/untar.c#L318-L319