c++,gcc,openssl,sha256Related issues-Collection of common programming errors


  • GManNickG
    c++ visual-c++ inclusion
    When I add an include guard to my header file for a Visual C++ project, it gives me the following warning and error:warning C4603: ‘_MAPTEST_H’ : macro is not defined or definition is different after precompiled header use Add macro to precompiled header instead of defining here.\MapTest.cpp(6) : use of precompiled header** // the precompiled header stdafx.h is included in this line.\MapTest.cpp(186) : fatal error C1020: unexpected #endifbut when I add the precompiled header before the in

  • Ghita
    c++ templates
    I havetemplate <typename ConcContainer>class WebBrowsingPolicyData{public:typedef ConcContainer<std::shared_ptr<WBRuleDetails>>::iterator iterator;…private:ConcContainer<std::shared_ptr<WBRuleDetails>> usersData_;CRITICAL_SECTION critSectionI get a compile error at line (Error 6 error C2238: unexpected token(s) preceding ‘;’) typedef ConcContainer<std::shared_ptr<WBRuleDetails>>::iterator iteratorHow can I make a typedef inside the template ? I mu

  • Josip Dorvak
    c++ polymorphism pure-virtual
    I have a class called course. Course has a pointer to a base class called Assessment.class Course{char* courseName;float fee;public:Assessment* assessment;Course();Course(Course&);Course(char*, float, Assessment *);~Course();friend ostream& operator <<(ostream& os, Course&); };Strickly for testing purposes, in the constructor i’m assigning the Assessment pointer to an ExamAssessment(a sub-class)Course::Course(){courseName = “something”;fee = 0;assessment = &ExamAssessme

  • Arkadiy
    c++ algorithm matrix macros
    I am working on a project to rotate a two dimensional array. When I use the macro to replace some codes, the results are surprising in that everything is exactly the same. The time it takes to finish the task can be significantly different. I have always thought the macro to be just a placeholder, but how could this happen?struct pixel {unsigned short red;unsigned short green;unsigned short blue; } ;//n is the # of elements in the two dimensional array void rotate1(int n, pixel *src, pixel *dst)

  • Mnementh
    c++ visual-studio-2008
    The following code (simplified example, that triggers the error) doesn’t compile with VS 2008:#include <math.h>void test() {long long int val1 = 1;long long int val2 = 2;long long int val3 = abs<long long int>(val1 / val2); }That gives an compiler-error (C2062) on the third line – the type __int64 is unexpected. What is the reason for this error? How can it be avoided?

  • Amokrane Chentir
    c++ stl
    I’ve got a very simple map :std::map<int, double> distances; distances[20.5] = 1; distances[19] = 2; distances[24] = 3;How do i know if there isn’t any returned value, when using a map::upper_bound() in this case for example:std::map<int, double>::iterator iter = distances.upper_bound(24);(24 is the max key so an unexpected result is returned, but how to know that through the code ? How to know i’ve reached the max key ?).Thanks !

  • Shantanu Gupta
    c# c++ casting void conceptual
    What will be the output if I write In C++ if(5) will be executed without any problem but not in C# same way will it be able to run.if(func()){} //in C# it doesn’t runs Why how does C# treats void and how in Turbo C++void func() { return; }if(null==null){}//runs in C#EDITif(printf(“Hi”){} //will run and enter into if statementif(printf(“”){}//will enter into else condition if found.This Question is not meant for those who are not aware of Turbo Compiler

  • Daniel Daranas
    c++ placement-new
    Is this safe? I’m not using any virtual functions in my actual implementation, but I’m tempted to believe that even if I was, it would still be safe.class Foo {Foo(){// initialize things}Foo( int ){new ( this ) Foo();} }

  • stepancheg
    c++ c windows sockets network-programming
    I hope you can help me out. I’m trying to send packets of 1000 bits across a network via TCP/IP and I was hoping to be able to use the Overlapped I/O technique in both Cygwin and Windows as well.In Cygwin, I am trying to use the “readv() and writev()” function calls to send 1000 bits across while in Windows, I am trying to use the WSASend() and WSARecv() APIs in the winsock2.h header file. It seems that I can ONLY send 1000 bits from Cygwin(client.cpp) to Windows(server.cpp). More than 1000 bits

  • user1858268
    c++ sorting pivot quicksort
    I have an assignment to implement a dual pivot quicksort algorithm. It seems to be working for vectors with small amounts of numbers, but when I try to sort a vector with for example 100000 I get segmentation fault. Any help? void quicksort_dual_pivot(vector <int> &A, int L, int R) {if(L>=R) return; int spivot = A[L]; //Error here.int bpivot = A[R]; if(spivot > bpivot){swap(A[R],A[L]);swap(spivot,bpivot); }int l = L+1; int g = R-1; for(int k=l;k<=g;k++){if(A[k] < spivot

  • Alex
    c gcc linux-kernel kernel driver
    Can I use #include <stdatomic.h> and atomic_thread_fence() with memory_order from C11 in Linux driver (kernel-space), or do I must to use Linux functions of memory-barriers: http://lxr.free-electrons.com/source/Documentation/memory-barriers.txt http://lxr.free-electrons.com/source/Documentation/atomic_ops.txtUsing:Linux-kernel 2.6.18 or greater GCC 4.7.2 or greater

  • Will Bradley
    c++ gcc syntax clang gcc-warning
    I’d like to have the compiler warn me if I’m not handling every if statement’s else condition. Does this exist in either clang or gcc?To clarify, I’m not trying to have this be on for all of my source code. However, there are sometimes entire files or large swaths of code for which I simply cannot afford to not think hard about every single else block, by design. So, I suppose, I’m really looking for a pragma I can turn on and off to enable and disable this for a few thousands of lines of ver

  • philippe
    c++ c gcc g++ dynamic-linking
    I’m currently writing an interface between a very low level C program to a higher level C++ program. The way they relate is through a linked list: The C program has a linked list, and the interface takes the information stored in each node in the linked list and converts that to a C++ vector. The process itself it’s not a program. The problem is how to call that C++ function from the C program. Let me give you some light on that:int importData(List *head, char * source, char * dest);is declared

  • Homunculus Reticulli
    c gcc
    I am getting the following warning: warning: left-hand operand of comma expression has no effectThe macros are defined below. I am compiling with GCC (4.4.3) on Linux. It is C code.#define MY_MAX(a,b) \({ __typeof__ (a) _a = (a); \__typeof__ (b) _b = (b); \_a > _b ? _a : _b; })#define MY_MIN(a,b) \({ __typeof__ (a) _a = (a); \__typeof__ (b) _b = (b); \_a < _b ? _a : _b; })How do I fix them to get rid of the warnings?[[Update]]Actually, I found the cause of the warning. It had nothing to do

  • GeeF
    linux gcc linker shared-libraries ld
    I’m sitting on an OpenSuse 11.1 x64 Box and I have a module that uses sigc++. When linking like this:g++ [a lot of o’s, L’s and l’s] -lsigc-2.0I get/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lsigc-2.0However the library is there. In the filesystem:$ sudo find / -name “libsigc-2.0*” /usr/lib64/libsigc-2.0.so.0.0.0 /usr/lib64/libsigc-2.0.so.0 /usr/lib64/libsigc-2.0.soIn ld.so.conf I have:/usr/lib64And when invoking ldconfig:$ ldconfig -v | grep sigc lib

  • Winmass
    c pointers gcc libc
    I am learning pointer in c i have written a small program , but i am getting segmentaion fault i dont know where i am having the issue please let me know the issue with the code , it is an array of pointers to string , which is in a pointer to structure . # include <stdio.h> #include <stdlib.h># include <string.h> char *sum(char **sol) ;char *summer_sum(char*** solcs) ; int main() { char* datum =”teststring”; sum(&datum); }char *sum(char** sol) { printf(“\n value

  • Dan D.
    objective-c gcc llvm clang
    The following code implements an NSProxy subclass which forwards methods to an NSNumber instance.However when calling [nsproxy floatValue] I get 0.0 under GCC 4.2.Under LLVM-Clang I get the correct answer 42.0.Any idea what is going on?(by the way this is running under Garbage Collection)-(id) init; {_result = [NSNumber numberWithFloat:42.0];return self; }- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {return [[_result class] instanceMethodSignatureForSelector:aSelector]; }- (v

  • Felixyz
    objective-c gcc compiler grammar keyword
    At the CocoaHeads Öresund meeting yesterday, peylow had constructed a great ObjC quiz. The competition was intense and three people were left with the same score when the final question was to be evaluated: How many reserved keywords does Objective-C add to C?Some spirited debate followed. All agreed that @interface, @implementation etc are all pre-processor directives rather than keywords, but how about something like in? It might be a keyword, but it’s not a reserved keyword. For example, the

  • Agnius Vasiliauskas
    c++ visual-studio-2010 gcc exception-handling exception-specification
    What is the standard behavior in cases when function throws exception not in valid exception list ? For example when I run this code:#include <iostream> #include <cstdlib>using namespace std;void NotLegal() throw(char) {throw 42; }void myunexpected () {cout << “exception not in list\n”;cin.get();exit(0); }int main() {set_unexpected(myunexpected);try {NotLegal();}catch(…) {cout << “exception catched”;cin.get();}return 0; }It behaves differently on GCC and Visual Studio C

  • Garrappachc
    c++ c linux gcc gnu
    I am writing the class for handling matrices (no suprise here – the name is Matrix). I was suprised when it turned out that I cannot use minor() method name that counts the minor matrix. The name is #defined in sys/syscalls.h. Is there a way to get rid of it?

  • pajooh
    git openssl debian gnutls
    recently, trying to clone a git repo from my debian(jessie) box, i’m facing this:fatal: unable to access ‘https://github.com/foo/bar/’: gnutls_handshake() failed: A TLS packet with unexpected length was received.as mentioned by ubuntu folks i used the git compiled with openssl, and now i get:fatal: unable to access ‘https://github.com/foo/bar/’: Unknown SSL protocol error in connection to github.com:443

  • Max
    ruby nginx openssl unicorn savon
    Having a hard time getting up and running with rails (3.1) app on private vps (Ubuntu 10.04.4 LTS).Getting error below when using savon to call a soap serviceOpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert unexpected message): lib/modules/soap_client.rb:32:in `create_payment’ app/controllers/payments_controller.rb:34:in `create’Strange as this exactly same application code works without a problem over at Heroku were I hosting it now as a res

  • Astron
    mysql shell scripting openssl mysqldump
    A portion of a script I use to backup MySQL databases has stopped working correctly after upgrading a Debian box to 6.0 Squeeze. I have tested the backup code via CLI and it works fine. I believe it is in the selection of the databases before the backup occurs, possibly something to do with the $skipdb variable. If there is a better way to perform the function then I’m will to try something new. Any insight would be greatly appreciated.$ sudo ./script.sh [: 138: information_schema: unexpected op

  • marketer
    ruby openssl mechanize
    I’m trying to connect to the server https://www.xpiron.com/schedule in a ruby script. However, when I try connecting:require ‘open-uri’ doc = open(‘https://www.xpiron.com/schedule’)I get the following error message:OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert unexpected message from /usr/local/lib/ruby/1.9.1/net/http.rb:678:in `connect’from /usr/local/lib/ruby/1.9.1/net/http.rb:678:in `block in connect’from /usr/local/lib/ruby/1.

  • Geoff Lanotte
    ruby openssl httpclient soap4r
    I am working against the level3 SOAP API. Everything was working wonderfully until recently when OpenSSL was updated. Here is the full output of the error message:OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert unexpected message):httpclient (2.1.5.2) lib/httpclient/session.rb:247:in `connect’httpclient (2.1.5.2) lib/httpclient/session.rb:247:in `ssl_connect’httpclient (2.1.5.2) lib/httpclient/session.rb:639:in `connect’httpclient (2.1.5.2

  • Steve
    postfix ssl-certificate dovecot openssl
    I’ve been trying to get Postfix and Dovecot set up for days and I think I have resolved all problems except for one that just came up. When I try to restart Dovecot I get the following error message:doveconf: Fatal: Error in configuration file /etc/dovecot/dovecot.conf: ssl enabled, but ssl_cert not set [….] Restarting IMAP/POP3 mail server: dovecotdoveconf: Fatal: Error in configuration file /etc/dovecot/dovecot.conf: ssl enabled, but ssl_cert not setWhen I check dovecot.conf, there is not

  • Daniel Kauffman
    security ssh openssl ssh-keygen
    From man 8 sshd with regards to the Authorized Keys File Format and the command=”command” option:Note that this command may be superseded by either an sshd_config(5) ForceCommand directive or a command embedded in a certificate.Using ssh-keygen -O force-command=”command” allows a command to be embedded in a certificate. But how does one verify that a command has not been embedded in a certificate? Along these same lines of preventing unexpected commands from being executed, does ForceCommand a

  • e-sushi
    encryption implementation file-encryption openssl
    I have recently begun studying crypto. If it’s one thing I have learned it’s that we should not implement our own crypto. Therefore we should look to using existing software and libraries.When I go to implement something that needs data security, there are many options — openssl, mcrypt, truecrypt, crypt, pycrypto, bouncycastle… how do I know what is “tried and true” with regard to crypto community scrutiny? This probably depends on the application, your implementation language, and the data

  • David
    java security openssl keystore jdk1.6
    I’ve a problem with the enum return value of KeyStore.aliases();FileInputStream is = new FileInputStream(“/tmp/file.p12”); List<String> aliases = new ArrayList<String>();KeyStore keystore = KeyStore.getInstance(“PKCS12”); keystore.load(is, password.toCharArray()); is.close();Enumeration<String> e=keystore.aliases(); while(e.hasMoreElements()) {// never reaches here because “e” is emptySystem.out.println(e.nextElement().toString());i++; }With Java version “1.6.0_22” Java(TM) SE

  • entropy
    windows-phone-8 windows-runtime openssl runtime winsock
    How to build OpenSSL for WP8?AFAIK, we must replace winsock.h by winsock2.h because WP8 only supports winsock2.h. And maybe we must replaces code to target WinRT architecture on WP8 (ThreadPool, …)The caveat is that we must build OpenSSL as WP8 static library, so that the output lib can be wrapped by WP8 runtime component, right ?

  • Bill the Lizard
    java bouncycastle sha256 elliptic-curve
    I am trying to generate a signature using ECDSA with SHA256 in Bouncy Castle as follows,I add the provider in the begining I have built the ECPrivatekey Signature s_oSignature = Signature.getInstance(“SHA256withECDSA”, BouncyCastleProvider.PROVIDER_NAME);but step 3 throws “java.security.NoSuchAlgorithmException: no such algorithm: SHA256withECDSA for provider BC”.But same “SHA256withECDSA” thing when replaced with “SHA1withECDSA” prceeds without any exception.How is it possible? I am using

  • Shehab Fawzy
    c# windows-8 sha256
    So in the old days I used to use System.Security.Cryptography which is not available in windows 8. what i found in windows 8 was windows.security but i didn’t find any examples on how to use Sha256 with a key. This is the old code that I used with System.Security.Cryptographystring appID = “appid”;string key = “password”;var hmacsha256 = new HMACSHA256(Encoding.Default.GetBytes(key));hmacsha256.ComputeHash(Encoding.Default.GetBytes(appID));string k = “”;foreach (byte test in hmacsha256.Hash){k +

  • McDermott
    ios objective-c hash sha256
    I want to create hash from a string. If the string has characters with accent (like é, o), it crashes with NSASCIIStringEncoding. It doesn’t crash with NSUTF8StringEncoding, but on the server it doesn’t match.+(NSString *) getSHA256FromString: (NSString *)clear {const char *s=[clear cStringUsingEncoding: NSASCIIStringEncoding];// NSUTF8StringEncoding works, but isn’t the same on serverNSData *keyData=[NSData dataWithBytes:s length:strlen(s)];uint8_t digest[CC_SHA256_DIGEST_LENGTH]={0};CC_SHA256(

  • aliasm2k
    php sha256 bitcoin
    I am making a bitcoin faucet using the coinbase api, and was looking to validate the address. I looked online to see if there are any good scripts, and couldnt find any so I decided to test and see if it was already built in the API, and it was! The the thing is that instead of just saying that is not a valid address it php displays a LONG error… Fatal error: Uncaught exception ‘Coinbase_ApiException’ with message ‘Please enter a valid email or bitcoin address’ in C:\xampp\htdocs\nahtnam\lib\C

  • user2782324
    sha256
    I was trying to use the sha2.c file from polarssl at this link,https://polarssl.org/sha-256-source-codeI am actually quite a newbie to this, but I was able to get this on Eclipse and when I tried to build it, it gives the errorc:/mingw/x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text+0x3d): undefined reference to `WinMain’do I have to pass some kind of data in the arguments? how can I find out how to use it?

  • millinon
    c++ gcc openssl sha256
    I’m writing a program to get myself acquainted with OpenSSL, libncurses, and UDP networking. I decided to work with OpenSSL’s SHA256 to become familiar with industry encryption standards, but I’m having issues with getting it working. I’ve isolated the error to the linking of OpenSSL with the compiled program. I’m working on Ubuntu 12.10, 64 bit. I have the package libssl-dev installed.Take, for instance, the C++ main.cpp:#include <iostream> #include <sstream> #include <string>

  • Frosty Z
    php encryption undefined trim sha256
    I have this php code:$password = sha256($_POST[‘password’]);but when I run this code it says:Fatal error: Call to undefined function sha256() in …. on line …ix it as What is wrong with this code and what must I do to fix this as I know that sha256 exists.I have also tried:$password = sha256(trim($_POST[‘password’]));But that doesn’t work either.

  • ThomasReggi
    node.js cryptography hmac sha256
    I can make an HMAC using the following:var encrypt = crypto.createHmac(“SHA256”, secret).update(string).digest(‘base64’);I am trying to decrypt an encoded HMAC with the secret:var decrypt = crypto.createDecipher(“SHA256”, secret).update(string).final(“ascii”);The following was unsuccessful. How can I decrypt a HMAC with the key?I get the following error:node-crypto : Unknown cipher SHA256crypto.js:155return (new Decipher).init(cipher, password);^ Error: DecipherInit error

Web site is in building