Compare commits

..

No commits in common. "e8b66a620755417e1162299e4911970d8b4d92d8" and "76afc0efd56dd0e407ea0b04ec4dfb7e538f144f" have entirely different histories.

2 changed files with 5 additions and 41 deletions

View File

@ -1,27 +0,0 @@
name: Continuous Integration
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
container: registry.fedoraproject.org/fedora:rawhide
steps:
- name: Checkout git repository
uses: actions/checkout@v4
- name: Install dependencies
run: dnf -y install cmake gcc-c++ libubsan libasan libogg-devel 'perl(Test::Harness)' 'perl(strict)' 'perl(warnings)' 'perl(utf8)' 'perl(Test::More)' 'perl(Test::Deep)' 'perl(Digest::MD5)' 'perl(File::Basename)' 'perl(File::Copy)' 'perl(IPC::Open3)' 'perl(List::MoreUtils)' 'perl(Symbol)' ffmpeg-free
- name: Build
env:
CXX: g++
CXXFLAGS: -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_DEBUG -O2 -flto=auto -g -Wall -Wextra -Werror=format-security -fstack-protector-strong -fstack-clash-protection -fcf-protection -fsanitize=address,undefined
LDFLAGS: -fsanitize=address,undefined
run: |
cmake -B target -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
cmake --build target
- name: Test
run: |
cmake --build target --target check

View File

@ -55,9 +55,7 @@ ot::opus_tags ot::parse_tags(const ogg_packet& packet)
// Comment count
if (pos + 4 > size)
throw status {st::cut_comment_count, "Comment count did not fit the comment header"};
uint32_t count;
memcpy(&count, data + pos, sizeof(count));
count = le32toh(count);
uint32_t count = le32toh(*((uint32_t*) (data + pos)));
pos += 4;
// Comments' data
@ -65,9 +63,7 @@ ot::opus_tags ot::parse_tags(const ogg_packet& packet)
if (pos + 4 > size)
throw status {st::cut_comment_length,
"Comment length did not fit the comment header"};
uint32_t comment_length;
memcpy(&comment_length, data + pos, sizeof(comment_length));
comment_length = le32toh(comment_length);
uint32_t comment_length = le32toh(*((uint32_t*) (data + pos)));
if (pos + 4 + comment_length > size)
throw status {st::cut_comment_data,
"Comment string did not fit the comment header"};
@ -138,16 +134,12 @@ ot::picture::picture(ot::byte_string block)
size_t desc_offset = mime_offset + 4 + mime_size;
if (storage.size() < desc_offset + 4)
throw status { st::invalid_size, "missing description in picture block" };
uint32_t desc_size;
memcpy(&desc_size, &storage[desc_offset], sizeof(desc_size));
desc_size = be32toh(desc_size);
uint32_t desc_size = be32toh(*reinterpret_cast<const uint32_t*>(&storage[desc_offset]));
size_t pic_offset = desc_offset + 4 + desc_size + 16;
if (storage.size() < pic_offset + 4)
throw status { st::invalid_size, "missing picture data in picture block" };
uint32_t pic_size;
memcpy(&pic_size, &storage[pic_offset], sizeof(pic_size));
pic_size = be32toh(pic_size);
uint32_t pic_size = be32toh(*reinterpret_cast<const uint32_t*>(&storage[pic_offset]));
if (storage.size() != pic_offset + 4 + pic_size)
throw status { st::invalid_size, "invalid picture block size" };
@ -165,8 +157,7 @@ ot::byte_string ot::picture::serialize() const
*reinterpret_cast<uint32_t*>(&bytes[0]) = htobe32(3); // Picture type: front cover.
*reinterpret_cast<uint32_t*>(&bytes[mime_offset]) = htobe32(mime_type.size());
std::copy(mime_type.begin(), mime_type.end(), std::next(bytes.begin(), mime_offset + 4));
uint32_t picture_data_size = htobe32(picture_data.size());
memcpy(&bytes[pic_offset], &picture_data_size, sizeof(picture_data_size));
*reinterpret_cast<uint32_t*>(&bytes[pic_offset]) = htobe32(picture_data.size());
std::copy(picture_data.begin(), picture_data.end(), std::next(bytes.begin(), pic_offset + 4));
return bytes;
}