Skip to content

Commit

Permalink
Merge pull request #20 from kenohassler/build-cleanup
Browse files Browse the repository at this point in the history
Build cleanup
  • Loading branch information
RickdeJager authored Oct 10, 2023
2 parents ff677b9 + ee1829d commit 5896978
Show file tree
Hide file tree
Showing 29 changed files with 61 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build-linux-i386:
# Build / test on a 32 bit container
container: i386/ubuntu:18.04
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v1
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ on:

jobs:
build-linux:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Install build dependencies
run: sudo apt install -y libmhash-dev libmcrypt-dev libjpeg62-dev zlib1g-dev build-essential cmake
run: sudo apt install -y libmhash-dev libmcrypt-dev libjpeg-dev zlib1g-dev build-essential cmake
- name: Compile project
run: |
mkdir -p build
Expand All @@ -24,12 +24,8 @@ jobs:
- name: Run (legacy) system tests
run: cd tests/steghide && ./systemtests.pl

# Get a recent python3 version to run the test script
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Run cracker tests
run: cd tests/stegseek && python test.py
run: cd tests/stegseek && python3.8 test.py

- name: Create a .deb package
run: bash package/package.sh
Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ cmake_minimum_required(VERSION 3.5)

project(stegseek VERSION 0.6)

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Update if necessary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# enforce modern C++, will not compile otherwise
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17")
endif()

add_subdirectory("src")
Expand Down
8 changes: 4 additions & 4 deletions src/Arguments.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,31 +146,31 @@ void Arguments::parse_Positional(std::vector<std::string> positionalArgs) {
switch (Command.getValue()) {
case CRACK: {
ArgString *posPtr[]{&StgFn, &WordlistFn, &ExtFn};
for (int i = 0; i < 3 && i < positionalArgs.size(); i++) {
for (size_t i = 0; i < 3 && i < positionalArgs.size(); i++) {
if (!posPtr[i]->is_set())
posPtr[i]->setValue(positionalArgs[i]);
}
} break;
case SEED_CRACK: {
// Extract this file into that file
ArgString *posPtr[]{&StgFn, &ExtFn};
for (int i = 0; i < 2 && i < positionalArgs.size(); i++) {
for (size_t i = 0; i < 2 && i < positionalArgs.size(); i++) {
if (!posPtr[i]->is_set())
posPtr[i]->setValue(positionalArgs[i]);
}
} break;
case EMBED: {
// Embed this in that and output there
ArgString *posPtr[]{&EmbFn, &CvrFn, &StgFn};
for (int i = 0; i < 3 && i < positionalArgs.size(); i++) {
for (size_t i = 0; i < 3 && i < positionalArgs.size(); i++) {
if (!posPtr[i]->is_set())
posPtr[i]->setValue(positionalArgs[i]);
}
} break;
case EXTRACT: {
// Extract this file into that file
ArgString *posPtr[]{&StgFn, &ExtFn};
for (int i = 0; i < 2 && i < positionalArgs.size(); i++) {
for (size_t i = 0; i < 2 && i < positionalArgs.size(); i++) {
if (!posPtr[i]->is_set())
posPtr[i]->setValue(positionalArgs[i]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/AuFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void AuFile::read(BinaryIO *io) {
break;
};
Header.encoding = (ENCODING)encoding;
} catch (BinaryInputError e) {
} catch (BinaryInputError &e) {
switch (e.getType()) {
case BinaryInputError::FILE_ERR: {
throw SteghideError(
Expand Down Expand Up @@ -152,7 +152,7 @@ void AuFile::write() {
for (unsigned long i = 0; i < Infofield.size(); i++) {
getBinIO()->write8(Infofield[i]);
}
} catch (BinaryOutputError e) {
} catch (BinaryOutputError &e) {
switch (e.getType()) {
case BinaryOutputError::FILE_ERR: {
throw SteghideError(
Expand Down
7 changes: 4 additions & 3 deletions src/AudioData.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class AudioData : public CvrStgObject {

virtual void read(BinaryIO *io, UWORD32 n = NoLimit) = 0;
virtual void write(BinaryIO *io, UWORD32 n = NoLimit) = 0;

virtual ~AudioData(void){};
};

/**
Expand All @@ -52,7 +54,6 @@ template <AUDIOSAMPLETYPE Type, class ValueType,
class AudioDataImpl : public AudioData {
public:
AudioDataImpl(CvrStgFile *f) : TheCvrStgFile(f){};
virtual ~AudioDataImpl(void){};

void read(BinaryIO *io, UWORD32 n = AudioData::NoLimit);
void write(BinaryIO *io, UWORD32 n = AudioData::NoLimit);
Expand Down Expand Up @@ -85,7 +86,7 @@ void AudioDataImpl<Type, ValueType, SampleValueType>::read(BinaryIO *io, UWORD32
Data[i] = readValue(io);
}
}
} catch (BinaryInputError e) {
} catch (BinaryInputError &e) {
switch (e.getType()) {
case BinaryInputError::FILE_ERR: {
throw SteghideError(
Expand Down Expand Up @@ -124,7 +125,7 @@ void AudioDataImpl<Type, ValueType, SampleValueType>::write(BinaryIO *io, UWORD3
for (UWORD32 i = 0; i < n; i++) {
writeValue(io, Data[i]);
}
} catch (BinaryOutputError e) {
} catch (BinaryOutputError &e) {
switch (e.getType()) {
case BinaryOutputError::FILE_ERR: {
throw SteghideError(
Expand Down
2 changes: 1 addition & 1 deletion src/AudioSampleValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ SampleValue *AudioSampleValue<Type, ValueType>::getNearestTargetSampleValue(EmbV
template <AUDIOSAMPLETYPE Type, class ValueType>
std::string AudioSampleValue<Type, ValueType>::getName(void) const {
char buf[128];
sprintf(buf, "%ld", (long)Value);
snprintf(buf, sizeof(buf), "%ld", (long)Value);
return std::string(buf);
}

Expand Down
8 changes: 4 additions & 4 deletions src/BmpFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ void BmpFile::readheaders() {
break;
}
}
} catch (BinaryInputError e) {
} catch (BinaryInputError &e) {
switch (e.getType()) {
case BinaryInputError::FILE_ERR: {
throw SteghideError(
Expand Down Expand Up @@ -688,7 +688,7 @@ void BmpFile::writeheaders() {
break;
}
}
} catch (BinaryOutputError e) {
} catch (BinaryOutputError &e) {
switch (e.getType()) {
case BinaryOutputError::FILE_ERR: {
throw SteghideError(
Expand Down Expand Up @@ -810,7 +810,7 @@ void BmpFile::readdata() {
while (!getBinIO()->eof()) {
atend.push_back(getBinIO()->read8());
}
} catch (BinaryInputError e) {
} catch (BinaryInputError &e) {
switch (e.getType()) {
case BinaryInputError::FILE_ERR: {
throw SteghideError(
Expand Down Expand Up @@ -865,7 +865,7 @@ void BmpFile::writedata() {
for (std::vector<unsigned char>::iterator i = atend.begin(); i != atend.end(); i++) {
getBinIO()->write8(*i);
}
} catch (BinaryOutputError e) {
} catch (BinaryOutputError &e) {
switch (e.getType()) {
case BinaryOutputError::FILE_ERR: {
throw SteghideError(
Expand Down
2 changes: 1 addition & 1 deletion src/BmpPaletteSampleValue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ SampleValue *BmpPaletteSampleValue::getNearestTargetSampleValue(EmbValue t) cons

std::string BmpPaletteSampleValue::getName() const {
char buf[128];
sprintf(buf, "i%ur%ug%ub%u", getIndex(), getRed(), getGreen(), getBlue());
snprintf(buf, sizeof(buf), "i%ur%ug%ub%u", getIndex(), getRed(), getGreen(), getBlue());
return std::string(buf);
}
2 changes: 1 addition & 1 deletion src/BmpRGBSampleValue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void BmpRGBSampleValue::addNTSVCandidates(std::vector<RGBTriple> &cands, const B

std::string BmpRGBSampleValue::getName() const {
char buf[128];
sprintf(buf, "r%ug%ub%u", getRed(), getGreen(), getBlue());
snprintf(buf, sizeof(buf), "r%ug%ub%u", getRed(), getGreen(), getBlue());
return std::string(buf);
}

Expand Down
9 changes: 7 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_definitions(-DHAVE_DEV_URANDOM)
add_definitions(-DHAVE_DEV_RANDOM)
add_definitions(-DHAVE_TERMIOS_H)
add_definitions(-DVERSION="0.6")
add_definitions(-DSTEGSEEK_VERSION="0.6")
add_definitions(-DSTEGHIDE_VERSION="0.5.1")

set (sources
Expand Down Expand Up @@ -67,6 +67,8 @@ file(GLOB headers
)

add_library(stegseek_lib ${sources} ${headers})
find_path(MCRYPT_INCLUDE_PATH mcrypt.h)
target_include_directories(stegseek_lib PUBLIC ${MCRYPT_INCLUDE_PATH})

set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
Expand All @@ -75,4 +77,7 @@ add_executable(stegseek main.cc)

install(TARGETS stegseek EXPORT stegseek DESTINATION bin)

target_link_libraries(stegseek PRIVATE stegseek_lib PUBLIC -lpthread -lz -lmcrypt -lmhash -ljpeg)
find_library(MCRYPT_LIBRARY mcrypt)
find_library(MHASH_LIBRARY mhash)
find_library(JPEG_LIBRARY jpeg)
target_link_libraries(stegseek PRIVATE stegseek_lib PUBLIC -lpthread -lz ${MCRYPT_LIBRARY} ${MHASH_LIBRARY} ${JPEG_LIBRARY})
2 changes: 1 addition & 1 deletion src/EmbData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void EmbData::addBits(BitString addbits) {
throw CorruptDataError(
_("attempting to read an embedding of version %d but steghide %s "
"only supports embeddings of version %d."),
Version, VERSION, CodeVersion);
Version, STEGHIDE_VERSION, CodeVersion);
}
NumBitsNeeded = EncryptionAlgorithm::IRep_size + EncryptionMode::IRep_size;
NumBitsRequested = AUtils::bminus<unsigned long>(NumBitsNeeded, Reservoir.getLength());
Expand Down
3 changes: 2 additions & 1 deletion src/Embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ void Embedder::embed() {
cvrstring = "\"" + Args.CvrFn.getValue() + "\"";
}
char buf[200];
sprintf(buf, _("embedding %s in %s..."), embstring.c_str(), cvrstring.c_str());
snprintf(buf, sizeof(buf), _("embedding %s in %s..."), embstring.c_str(),
cvrstring.c_str());

prout = new ProgressOutput(std::string(buf));
} else if (Args.Verbosity.getValue() == VERBOSE) {
Expand Down
2 changes: 1 addition & 1 deletion src/Extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class Extractor {
private:
std::string StegoFileName;
std::string Passphrase;
bool passphraseSet;
UWORD32 seed;
bool passphraseSet;
};

#endif // ndef SH_EXTRACTOR_H
4 changes: 2 additions & 2 deletions src/JpegFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,15 @@ void JpegFile::printFrequencies(const std::map<SampleKey, unsigned long> &freqs)
for (std::map<SampleKey, unsigned long>::const_iterator pit = freqs.begin();
pit->first < 2147483648UL /* 2^31 */; pit++) {
char buf[30];
sprintf(buf, "%ld: %lu", (long)pit->first, pit->second);
snprintf(buf, sizeof(buf), "%ld: %lu", (long)pit->first, pit->second);
output.push_back(std::string(buf));
}

// insert the negative dct coeffs into output list
for (std::map<SampleKey, unsigned long>::const_reverse_iterator nit = freqs.rbegin();
nit->first > 2147483648UL /* 2^31 */; nit++) {
char buf[30];
sprintf(buf, "%ld: %lu", (long)nit->first, nit->second);
snprintf(buf, sizeof(buf), "%ld: %lu", (long)nit->first, nit->second);
output.push_front(std::string(buf));
}

Expand Down
2 changes: 1 addition & 1 deletion src/JpegSampleValue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ UWORD32 JpegSampleValue::calcDistance(const SampleValue *s) const {

std::string JpegSampleValue::getName(void) const {
char buf[128];
sprintf(buf, "%d", DctCoeff);
snprintf(buf, sizeof(buf), "%d", DctCoeff);
return std::string(buf);
}
2 changes: 1 addition & 1 deletion src/RandomSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RandomSource::RandomSource() {
#endif
}

RandomSource::~RandomSource() {
RandomSource::~RandomSource() noexcept(false) {
if (RandomInput != NULL) {
if (fclose(RandomInput) != 0) {
throw SteghideError(_("could not close random input file."));
Expand Down
2 changes: 1 addition & 1 deletion src/RandomSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BitString;
class RandomSource {
public:
RandomSource(void);
~RandomSource(void);
~RandomSource(void) noexcept(false);

/**
* get a random byte
Expand Down
6 changes: 3 additions & 3 deletions src/SampleValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ class SampleValue {
UWORD32 *NumEdges;
};

struct SampleValuesEqual : public std::binary_function<SampleValue *, SampleValue *, bool> {
struct SampleValuesEqual {
bool operator()(const SampleValue *s1, const SampleValue *s2) const { return (*s1 == *s2); }
};

struct SampleValuesLess : public std::binary_function<SampleValue *, SampleValue *, bool> {
struct SampleValuesLess {
bool operator()(const SampleValue *s1, const SampleValue *s2) const { return (*s1 < *s2); }
};

struct SampleValueHash : public std::unary_function<SampleValue *, size_t> {
struct SampleValueHash {
size_t operator()(const SampleValue *s) const {
std::hash<UWORD32> h;
return h(s->getKey());
Expand Down
2 changes: 1 addition & 1 deletion src/Session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void Session::printEncInfo() {
}

void Session::printVersion() {
fprintf(stderr, "StegSeek %s - https://github.com/RickdeJager/StegSeek\n", VERSION);
fprintf(stderr, "StegSeek %s - https://github.com/RickdeJager/StegSeek\n", STEGSEEK_VERSION);
if (Args.Verbosity.getValue() == VERBOSE) {
printSteghideVersion();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ std::string Utils::formatHRSize(unsigned long size) {
}

char buf[15];
sprintf(buf, "%.1f %s", s, unit.c_str());
snprintf(buf, sizeof(buf), "%.1f %s", s, unit.c_str());
return std::string(buf);
}

std::string Utils::stripDir(std::string s) {
unsigned int start = 0;
size_t start = 0;
if ((start = s.find_last_of("/\\")) == std::string::npos) {
start = 0;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/WKSConstructionHeuristic.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class WKSConstructionHeuristic : public MatchingAlgorithm {
* If both v1 and v2 have degree 0, then the vertex with the greater label
* is defined to have the "longer shortest edge".
**/
class LongerShortestEdge : public std::binary_function<Vertex *, Vertex *, bool> {
class LongerShortestEdge {
public:
bool operator()(const Vertex *v1, const Vertex *v2);
};
Expand Down
8 changes: 4 additions & 4 deletions src/WavFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void WavFile::readdata(void) {
while (!getBinIO()->eof()) {
UnusedAfterData.push_back(getBinIO()->read8());
}
} catch (BinaryInputError e) {
} catch (BinaryInputError &e) {
switch (e.getType()) {
case BinaryInputError::FILE_ERR: {
throw SteghideError(
Expand Down Expand Up @@ -285,7 +285,7 @@ void WavFile::writedata(void) {
it != UnusedAfterData.end(); it++) {
getBinIO()->write8(*it);
}
} catch (BinaryOutputError e) {
} catch (BinaryOutputError &e) {
switch (e.getType()) {
case BinaryOutputError::FILE_ERR: {
throw SteghideError(
Expand Down Expand Up @@ -330,7 +330,7 @@ void WavFile::readheaders() {
}

datachhdr = chhdr;
} catch (BinaryInputError e) {
} catch (BinaryInputError &e) {
switch (e.getType()) {
case BinaryInputError::FILE_ERR: {
throw SteghideError(
Expand Down Expand Up @@ -378,7 +378,7 @@ void WavFile::writeheaders() {
}

datachhdr->write(getBinIO());
} catch (BinaryOutputError e) {
} catch (BinaryOutputError &e) {
switch (e.getType()) {
case BinaryOutputError::FILE_ERR: {
throw SteghideError(
Expand Down
2 changes: 1 addition & 1 deletion src/WavPCMSampleValue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ UWORD32 WavPCMSampleValue::calcDistance(const SampleValue *s) const {

std::string WavPCMSampleValue::getName() const {
char buf[128];
sprintf(buf, "%d", Value);
snprintf(buf, sizeof(buf), "%d", Value);
return std::string(buf);
}
Loading

0 comments on commit 5896978

Please sign in to comment.