Skip to content
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

S3_get_object leaks if the object doesn't exist #92

Open
bsdinis opened this issue Jul 3, 2019 · 0 comments
Open

S3_get_object leaks if the object doesn't exist #92

bsdinis opened this issue Jul 3, 2019 · 0 comments

Comments

@bsdinis
Copy link

bsdinis commented Jul 3, 2019

when calling S3_get_object when the key in question doesn't exist in bucket, valgrind reports a bunch of conditional jumps on unitialized values and a leak.

example program

#include <stdio.h>
#include "libs3.h"

static S3Status getObjectDataCallback(int bufferSize, const char *buffer
{
  FILE *outfile = (FILE *) callbackData;
  if (bufferSize <= 0) return S3StatusOK;
  size_t wrote = fwrite(buffer, 1, bufferSize, outfile);
  return ((wrote < (size_t) bufferSize) ? S3StatusAbortedByCallback : S3
}

int s3_get(const char * key, FILE * stream)
{
  S3GetObjectHandler getObjectHandler = {
    responseHandler,
    &getObjectDataCallback
  };

  S3_get_object(
      &bucketContext,
      key,
      NULL,
      0,
      0,
      NULL,
      0,
      &getObjectHandler,
      stream
      );
  return 0;
}

int main(int argc, char ** argv)
{
  if (argc != 2) {
    fprintf(stderr, "usage: %s key\n", argv[0]);
    return -1;
  }

  S3_initialize(NULL, S3_INIT_ALL, host);

  s3_get(argv[1], stdout);                                              

  S3_deinitialize();


  return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant