Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 738025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:47:21+00:00 2026-05-14T07:47:21+00:00

I’m running Valgrind and I’m getting the following error (this is not the only

  • 0

I’m running Valgrind and I’m getting the following error (this is not the only one):

==21743== Conditional jump or move depends on uninitialised value(s)
==21743==    at 0x4A06509: index (mc_replace_strmem.c:164)
==21743==    by 0x33B7CBB3CD: gaih_inet (in /lib64/libc-2.5.so)
==21743==    by 0x33B7CBD629: getaddrinfo (in /lib64/libc-2.5.so)
==21743==    by 0x401A5F: tunnelURL (proxy.c:336)
==21743==    by 0x40142A: client_thread (proxy.c:194)
==21743==    by 0x33B8806616: start_thread (in /lib64/libpthread-2.5.so)
==21743==    by 0x33B7CD3C2C: clone (in /lib64/libc-2.5.so)

My tunnelURL() function looks like this (C code):

char * tunnelURL(char *url) {
 char * a = strstr(url, "//");
 a += 2;
 char * path = strstr(a, "/");

 char host[256];
 strncpy (host, a, strlen(a)-strlen(path));

 /*
  * The following is courtesy of Beej's Guide
  */
 int status;
 int proxySocketFD;
 struct addrinfo hints;
 struct addrinfo *servinfo; // will point to the results

 memset(&hints, 0, sizeof(hints)); // make sure the struct is empty
 hints.ai_family = AF_INET; // don't care IPv4 or IPv6
 hints.ai_socktype = SOCK_STREAM; // TCP stream sockets
 hints.ai_flags = AI_PASSIVE; // fill in my IP for me

 if ((status = getaddrinfo(host, "80", &hints, &servinfo)) != 0) {
  perror("getaddrinfo() fail");
  exit(1);
 }

 // create socket
 if ((proxySocketFD = socket(servinfo->ai_family, servinfo->ai_socktype, servinfo->ai_protocol)) == -1) {
  perror("proxy socket() fail");
  exit(1);
 }

 // connect
 if (connect(proxySocketFD, servinfo->ai_addr, servinfo->ai_addrlen) != 0) {
  printf("connect() fail");
  exit(1);
 }

 // construct request
 char request[strlen(path) + strlen(host) + 26];
 sprintf(request, "GET %s HTTP/1.1\r\nHost: %s\r\n\r\n", path, host);
 printf("%s", request);

 // send request
 send(proxySocketFD, request, strlen(request), 0);

 // receive response
 int i = 0;
 int amntRecvd = 0;
 char *pageContentBuffer = (char*) malloc(4096 * sizeof(char));
 while ((amntRecvd = recv(proxySocketFD, pageContentBuffer + i, 4096, 0)) > 0) {
  i += amntRecvd;
  realloc(pageContentBuffer, i * 4096 * sizeof(char));
 }

 // close proxy socket
 close(proxySocketFD);

 // deallocate memory
 freeaddrinfo(servinfo);

 return pageContentBuffer;

}

Line 336 corresponds to the if statement with the getaddrinfo() function call. I’m not really sure what I haven’t initialized. The string I’m passing in “should” be already set. I’m printing it out just fine. I also get another error corresponding to the same line of code:

==21743== Use of uninitialised value of size 8
==21743==    at 0x33B7D05816: __nscd_cache_search (in /lib64/libc-2.5.so)
==21743==    by 0x33B7D0438B: nscd_gethst_r (in /lib64/libc-2.5.so)
==21743==    by 0x33B7D04B26: __nscd_gethostbyname2_r (in /lib64/libc-2.5.so)
==21743==    by 0x33B7CE9F5E: gethostbyname2_r@@GLIBC_2.2.5 (in /lib64/libc-2.5.so)
==21743==    by 0x33B7CBC522: gaih_inet (in /lib64/libc-2.5.so)
==21743==    by 0x33B7CBD629: getaddrinfo (in /lib64/libc-2.5.so)
==21743==    by 0x401A5F: tunnelURL (proxy.c:336)
==21743==    by 0x40142A: client_thread (proxy.c:194)
==21743==    by 0x33B8806616: start_thread (in /lib64/libpthread-2.5.so)
==21743==    by 0x33B7CD3C2C: clone (in /lib64/libc-2.5.so)

Any ideas as to what might becausing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:47:22+00:00Added an answer on May 14, 2026 at 7:47 am

    You’re not using realloc() correctly. realloc() may move the allocated block, and it returns the new address of the block – so you need to assign that return value to pageContentBuffer (iff it’s not NULL).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.