× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi John,

Is the problem because the second message is too short and the function is
picking up garbage?

Theoretically, it shouldn't matter. QSH is calculating the length of your string and passing that to the API. The API shouldn't care how long/short the data is, as long as the length is reported correctly.

Or, guessing here, and just a guess, is the parameter
following '%s', which is x'%08x', the problem here? I thought that was the
length of the message.

the printf utility is supposed to format a message. When it sees %08x it's supposed to output an 8-character hexadecimal number. For example, if you did this:

> printf "%08x\n" 1024
00000400
$

So when I coded this: printf "x'%08x'" ${#doubledquotes} it should output the length of the doubledquotes variable in an 8-character hexadecimal string. If yours is 38 characters long, it should output
x'00000026' (since x'26' is decimal 38). That's how the appropriate length is supposed to be passed to the API.

If you think that's not working correctly, you can debug it easily enough by adding the following right before the system command:

echo "$cmd"

it should print the contents of the $cmd variable before running it, and you'll be able to verify that it's building a valid command string to call the API.


But, if that is the case, then shouldn't both invocations of the
function throw the message?

No... memory corruption is one of those things that's hard to predict. Usually, you don't corrupt the actual statement you're on, you corrupt something else. You're overwriting a space in memory, whatever data happens (by some luck) to come immediately after the variable you were using. It's hard to predict what will happen to be in that spot in memory. It could be corrupting stuff you're already finished with, in which case you may see no error at all. It could be corrupting something that hasn't been used yet, in which case you'll see the error later. It could be corrupting unused memory, in which case you might never notice any problems. It could be corrupting a pointer that will be used later, in which case you get the MCH3601. It could be running past the end of the space object, in which case your program would crash with a different MCH error. It's hard to predict, because you don't know what will happen to be immediately after the temporary memory that QSH uses to store the string...

I don't see anything in the code you posted that would corrupt memory, and it's not causing any problems on my system. Of course, there's always a chance that I'm overlooking something, and it's just by sheer luck (or lack thereof) that it's working for me.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.