zeek/src/FileAnalyzer.h
Jon Siwek 2481f9f837 Fix possible null pointer dereference in identify_data BIF.
There was no check/handling for if magic_buffer() returns null.
Also centralized libmagic calls for consistent error handling/output.
2013-02-27 16:04:36 -06:00

36 lines
678 B
C++

// Analyzer for connections that transfer binary data.
#ifndef FILEANALYZER_H
#define FILEANALYZER_H
#include "TCP.h"
#include <magic.h>
class File_Analyzer : public TCP_ApplicationAnalyzer {
public:
File_Analyzer(Connection* conn);
virtual void Done();
virtual void DeliverStream(int len, const u_char* data, bool orig);
static Analyzer* InstantiateAnalyzer(Connection* conn)
{ return new File_Analyzer(conn); }
static bool Available() { return file_transferred; }
protected:
File_Analyzer() {}
void Identify();
static const int BUFFER_SIZE = 1024;
char buffer[BUFFER_SIZE];
int buffer_len;
static magic_t magic;
static magic_t magic_mime;
};
#endif