mchehab / zbar

ZBar is an open source software suite for reading bar codes from various sources, including webcams. As its development stopped in 2012, I took the task of keeping it updated with the V4L2 API. This is the main repository for it. There's a clone at at LinuxTV.org, and another one at gitlab.
https://linuxtv.org/downloads/zbar/
GNU Lesser General Public License v2.1
986 stars 206 forks source link

Suggest fuzzer for zbar_image_set_data() and zbar_image_convert(). #233

Open autofuzzoss opened 2 years ago

autofuzzoss commented 2 years ago

I suggest this fuzzer for continuous vulnerability checks.

/*
 * This fuzzer is generated by UTopia with some manual modifications.
 * (UTopia Project: https://github.com/Samsung/UTopia)
 */

#include <gtest/gtest.h>
#include <stdio.h>
#include <stdlib.h>

#include <zbar.h>
#include "FuzzedDataProvider.h"

using namespace zbar;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, uint32_t size) {
  FuzzedDataProvider provider(data, size);
  auto autofuzz0 = provider.ConsumeRemainingBytesAsString();

  zbar_image_t *img = zbar_image_create();
  if(!img)
    return 0;
  zbar_image_set_size(img, 8, 8);
  zbar_image_set_format(img, zbar_fourcc('J', 'P', 'E', 'G'));
  zbar_image_set_data(img, autofuzz0.c_str(), autofuzz0.size(), NULL);
  zbar_image_t *test = zbar_image_convert(img, zbar_fourcc('Y', '8', '0', '0'));
  if(!test)
    return 0;
  free(img);
  free(test);
  return 0;
}
Abdull commented 1 week ago

this issue is mentioned in https://blog.trailofbits.com/2024/10/31/fuzzing-between-the-lines-in-popular-barcode-software/