I, recently I use fopen_s:
errno_t err = fopen_s( &fp, filename, mode );
and I get errno_t as zero, which means no error occured, but I didn't get a valid fp, actually, it is unchanged.
What possible is this situation?
Apparently, it encounter a NULL file pointer, which is not as expected, for why it encounter such a problem, please refer to this: Bad Pointer error when using File* object
Related
Diclaimer
In the first place this is a recap on recent development activities.
I am writing this down for lost souls - as I could not find any post containing this error except:
RSA encryption/decryption implementing in Swift from Android Java code
The Problem
During decryption of a cyphertext with a given private key, iOS throws this error:
Optional(Swift.Unmanaged<__C.CFErrorRef>(_value: Error Domain=NSOSStatusErrorDomain Code=-50 "RSAdecrypt wrong input (err -27)" UserInfo={numberOfErrorsDeep=0, NSDescription=RSAdecrypt wrong input (err -27)}))
For the sake of readability and search engine optimization the same error is given in a style which is more easy to be read:
Optional(
Swift.Unmanaged<__C.CFErrorRef>(
_value: Error
Domain=NSOSStatusErrorDomain
Code=-50 "RSAdecrypt wrong input (err -27)"
UserInfo={
numberOfErrorsDeep=0,
NSDescription=RSAdecrypt wrong input (err -27)
}
)
)
The Question
What are likely reasons for receiving this error?
However
My knowledge so far is given in one of the answers below ;-)
As mentioned by #not2savvy, I better answer as far as known here instead of 'within the question part' ... .. .
The good news
You probaply solved several problems already, such as:
Base64 decoding error
-> In case your ciphertext/private key had to be transformed back to binary
Algorithm error
-> Mismatch of PrivateKey in regards of the needed algorithm (e.g.: RSA)
Size error
-> Mismatch of Ciphertext- and Keysize
... .. . you are not far from the solution ;-)
The bad news
You probaply have the wrong private key to decrypt the given cyphertext.
Something else is wrong with your key, which I do know nothing about.
In my matlab script I am sending a mail to me with an exception that tells me, when an error happens, which kind of error it is.
The problem I am facing is the fact that the ME exception is not showing me where the error happens (which line and which part of the code) as matlab usually does. I can't see the error in the matlab terminal too (the program just stops running). The code that sends the mail with the error is below:
try
% my script which can fail....
demo
catch ME
% An error will put here.
errorMessage = sprintf('Error in demo. The error is: %s', ME.message);
%this function just sends the mail
sendmail2me(errorMessage);
What I missed?
The exception ME is an MException object which contains an identifier, the message, a cause and the stack. The identifier is only there to allow MATLAB an unique identification of an error. The message contains a description of the error.
The cause contains an array of MExceptions which have led to the current exception. This allows you to track the exceptions to find the root of your error. As the cause is a (possibly empty) array of MException objects, you could go through the cause in an array and write the information into the mail.
Most important for you is the stack. It is a struct containing three fields: file, name and line. File is the full path to the file/function where the error occurred. Name is (obviously) the name of the file and in line (again obviously) the line where the exception occurred is saved. The stack can also be an array if the error occurred in a function called from you function/script. It would therefore be best to go through stack in a for loop, and concatenate the error message and the contents of the stack.
try
demo;
catch ME
errormsg = sprintf('%s\n',ME.message);
for k=1:length(ME.stack)
errormsg = sprintf('%s\nError in %s (line %d)\n', ...
errormsg,ME.stack(k).name,ME.stack(k).line);
end
sendmail2me(errormsg);
end
You find more detailed information on Exceptions in the MATLAB help pages.
I'm writing a simple program to decode any input audio file into pcm16/mono/wav file, using libav. Or, I supposed it was simple.
After struggling a lot, reading lots of sample code (like avconv/avplay), I've managed to code something that should work.
However, it's not working. The demuxing/decoding parts seems to work fine, but the encoding part failed with the following message:
mathematics.c:61: av_rescale_rnd: Assertion `c > 0' failed.
Here is the code extract:
printf("Fill Frame\n");
avcodec_fill_audio_frame(oframe, _oCodecCtx->channels, _oCodecCtx->sample_fmt, frame->data[0], frame->linesize[0], 0);
printf("Frame filled\n");
ret = avcodec_encode_audio2(_oCodecCtx, &opkt, oframe, &got_packet);
if (ret < 0) {
printf("Error encoding audio frame\n");
return 1;
}
"Fill Frame" And "Frame filled" are displayed before the error appears. So, I think its thrown by avcodec_encode_audio2. However, this function doesn't call av_rescale_rnd in its source code.
So here is the question: is there a way to know who called this function, without modifying/recompiling libav source code?
I'm calling AudioSessionInitialize like so
OSStatus result = AudioSessionInitialize(NULL,NULL,interruptionListener,NULL);
and getting the result 0xbfffde94 (i.e. -1073750040) which doesn't match anything in the documentation, which are all readable 4CC's like '!ini' and so forth.
The good news is that it seems like the call worked. Nevertheless, can anyone shed light on this error code?
EDIT: The above error code is returned in the simulator. On the device the error code is 2fffe810.
Since these results are bogus and not defined or described by Apple, I am left with only but one assumption; you have a weird mix of Frameworks installed - possibly old versions mixed with newer ones. So all I could recommend is to reinstall the entire iPhone SDK.
I figured it out. I'm an idiot. There was an error in the macro I had wrapping the call & reporting the error, which called the AudioSessionInitialize twice. That doesn't quite explain the error code I saw, but it sure isn't worth wondering about.
UPDATE: Actually this is pretty slapstick so I'm going to explain.
The offending macro was originally:
#define CHECK(S) { OSStatus err = (S); if (S) printf("Error %x at \"%s\"\n", err, #S);}
so bug #1 is the if (S) which should be if if (err). Hence I'm repeating every call to the audio system, which explains various other weird things, so I'm very happy I tried to figure out what had seemed like a harmless anomaly. In this case the second call complained that the audio session was already initialized.
But why the weird error code? I wanted to see the 4CC's so I changed the macro to this, carrying the error along:
#define CHECK(S) { OSStatus err[2] = {S,0}; if (S) printf("Error %x '%4s' at \"%s\"\n", err, &err, #S); }
(The second OSStatus of 0 terminates the string defined by the 4CC first OSStatus, so I can print it with format %s.) But I forgot to change err to err[0], so it was indeed printing the address of the err array. This I'm pretty sure is correct now:
#define CHECK(S) { OSStatus err[2] = {S,0}; if (*err) printf("Error %x '%4s' at \"%s\"\n", *err, err, #S); }
Look at the OSStatus variable in the debugger's list of variables (lower left). Right click on it and select View Value As->Bytes (Hex with ASCII). Read the 4-letter code backwards.* This should match one of the documented result codes.
A value of 1768843636 is 74 69 6e 69 when viewed this way. Next to that the debug window shows 'tini'. Turn that around and you get 'init', which the documentation says is kAudioSessionAlreadyInitialized.
*No, I don't know why.
I recently ran into a problem that I couldn't find discussed anywhere on the internet - I was initializing an AVAudioPlayer to play an audio file, and getting the following error:
Error Domain=NSOSStatusErrorDomain Code=-50 "Operation could not be completed. (OSStatus error -50.)
As it turns out, I had made a mistake creating my NSURL to send to the audio player init method, resulting in the NSURL object being null. Stupid mistake, pretty easy to find when debugging, but I thought I'd list it here just in case someone else does the same thing.
“ OSStatus error -50” means paramErr, an old-style Mac error code indicating a bad parameter.
Regarding the comment from Brynjar:
The Apple NSURL Class Reference describing URLWithString states
To create NSURL objects for file system paths, use
fileURLWithPath:isDirectory: instead.
I have found that using URLWithString for file system paths generates the error reported by pix0r and therefore could be another explanation for error code = -50
Make sure your NSURL is valid, or you will get error code -50 "Operation could not be completed".
I'm adding my version of the issue and solution because I encountered the error with a print statement. I think it was related to string interpolation and or trying to forcibly print nsattributedstrings. I attempted to do the following.
print("THE ARRAY COUNT IS : \(unwrappedResults.count)\n\n\n
THE FULL ARRAY IS THE FIRST WHOLE RESULT IS: \(unwrappedResults)\n\n\n \ (unwrappedResults[0])\n
THE ATTRIBUTED FULL TEXT IS: \(unwrappedResults[0].attributedFullText)\n\n\n
THE ATTRIBUTED PRIMARY TEXT IS: \(unwrappedResults[0].attributedPrimaryText)\n\n\n
THE ATTRIBUTED SECONDARY TEXT IS: \(unwrappedResults[0].attributedSecondaryText)\n\n\n")
something about this was incorrect and no print would occur. I would receive the error following errors in my console.
boringssl_metrics_log_metric_block_invoke(131) Failed to log metrics
&
boringssl_metrics_log_metric_block_invoke(133) Error Domain=NSOSStatusErrorDomain Code=-50 "Unsupported xpc type"
UserInfo={NSDescription=Unsupported xpc type}
I fixed this issue by changing the way I unwrapped/the variables values. Fundamentally I think I was trying to print something using string interpolation that could not be printed and that is what caused this error.