ORA-00932: inconsistent datatypes: expected CHAR got NUMBER

I am trying to SUBSTR the first 3 character in use this query -> CASE WHEN (RMSTMP_PNG.ota_activity_lotinfo.KEY = ‘TestProgram’) THEN TO_CHAR(SUBSTR(RMSTMP_PNG.ota_activity_lotinfo.VALUE,1,3)) ELSE 0 END AS Test1 But it return me this ORA-00932: inconsistent datatypes: expected CHAR got NUMBER 00932. 00000 – "inconsistent datatypes: expected %s got %s". May i know what wrong in my query? I tried to use To_NUMBER or To CHAR, it also return me same error. Appreciate if someone could help on this issue. Below is my query:

SELECT RMSTMP_PNG.ota_activity.EQP_ID, SUM(CASE WHEN (RMSTMP_PNG.ota_activity.MESSAGE='Load lot success.' AND RMSTMP_PNG.ota_activity_lotinfo.KEY = 'Quantity') THEN 1 ELSE 0 END) AS LOT_ID, SUM(CASE WHEN (RMSTMP_PNG.ota_activity.MESSAGE='Load lot success.' AND RMSTMP_PNG.ota_activity_lotinfo.KEY = 'Quantity') THEN TO_NUMBER(RMSTMP_PNG.ota_activity_lotinfo.VALUE) ELSE 0 END) AS QUANTITY, CASE WHEN (RMSTMP_PNG.ota_activity_lotinfo.KEY = 'TestProgram') THEN TO_CHAR(SUBSTR(RMSTMP_PNG.ota_activity_lotinfo.VALUE,1,3)) ELSE 0 END AS Test1 FROM RMSTMP_PNG.ota_activity  FULL OUTER JOIN RMSTMP_PNG.ota_activity_lotinfo ON RMSTMP_PNG.ota_activity.ID = RMSTMP_PNG.ota_activity_lotinfo.ID  WHERE RMSTMP_PNG.ota_activity.MODIFIED_DATE >= to_date('27-Sep-2020') AND RMSTMP_PNG.ota_activity.MODIFIED_DATE < to_date('27-Sep-2020') + 1  group by RMSTMP_PNG.ota_activity.EQP_ID,RMSTMP_PNG.ota_activity_lotinfo.VALUE, RMSTMP_PNG.ota_activity_lotinfo.KEY order by RMSTMP_PNG.ota_activity.EQP_ID 

If has action not working as expected

I’m using ACF Blocks in a theme I’m building.

Here’s my block template file within /my-plugin/template-parts/blocks/page-intro/page-intro.php:

<?php /**  * Page Intro Block Template.  *  * @param   array $  block The block settings and attributes.  * @param   string $  content The block inner HTML (empty).  * @param   bool $  is_preview True during AJAX preview.  * @param   (int|string) $  post_id The post ID this block is saved to.  */ ?> <?php do_action('acf_add_class'); ?> <div class="page-intro-wrapper" style="background: url(<?php esc_url( the_field('background_image') ); ?> )">     <div class="page-intro">         <h2><?= esc_html( get_field('title') ); ?></h2>         <?= get_field('text'); ?>     </div> </div> 

You’ll see that I’ve added <?php do_action('acf_add_class'); ?> at the top.

I then have the following via my plugin:

/**  * Add custom classes to body  */ function body_classes( $  classes ) {          if ( has_action('acf_add_class') ) {         $  classes[] = 'page-intro';     }          return $  classes; } add_filter( 'body_class', 'body_classes' ); 

I was hoping that if ( has_action('acf_add_class') ) { would trigger the condition and add the class, but this hasn’t worked.

I’ve also tried this within the body_class filter:

if ( has_action('acf_add_class', get_queried_object_id() ) ) {     $  classes[] = 'page-intro'; } 

This question may be off-topic if the issue is ACF related.

Any ideas?

I am not getting output for the below batch file as expected [closed]

I wrote the below mentioned test batch file… But while executing it, when I give input as "How are you" then the file automatically gets terminated.

@echo off echo Hi! echo Happy to be at your service 🙂 :start set /a A = How are you set /p help="How may I help you? " if /i %help% EQU excel (start excel) else (if /i %help% EQU %A% (echo I am good! Thanks for asking)) goto start

But, if I write…

@echo off echo Hi Sir! echo Happy to be at your service 🙂 :start set /a A = How set /p help="How may I help you? " if /i %help% EQU excel (start excel) else (if /i %help% EQU How (echo I am good Sir! Thanks for asking)) goto start

and when I give input as "How"… I get the output as expected.

The output that I get at this case is…

Hi! Happy to be at your service 🙂 How may I help you? how I am good! Thanks for asking How may I help you?

Kindly help me in solving this issue.

Setuid on rcp not working as expected

While pentesting in a lab, came across an rcp binary with setuid bit which looked like a potential privilege escalation vector.

bash-3.1$   ls -l /usr/bin/rcp -rwsr-xr-x 1 root root 18544 May 18  2007 /usr/bin/rcp 

Following the explanation at https://securiteam.com/exploits/6b00l1p0bc/ , I tried the following:

bash-3.1$   /usr/bin/rcp 'bob bobalina;/usr/bin/id;' uid=48(apache) gid=48(apache) groups=48(apache) bash: command not found 

My understanding is that since rcp is setuid as root, any command executed by it must be run as root. Why am I then seeing the output of /usr/bin/id as apache, which is the user I am running as?

I’m not a great Linux guy so if I’m missing something obvious, please let me know.

I’ve also tried the command injection with backticks, got the same result:

bash-3.1$   /usr/bin/rcp ``bob bobalina;/usr/bin/id;`` uid=48(apache) gid=48(apache) groups=48(apache) bash: command not found 

Are the open ports 53,139,445 and 49152 expected on a Linux machine? [closed]

I ran an nmap stealth scan on my home network (using linux) and this is my result. I don’t know why netbios is open – I ran the samba command and it is not recognised, so I don’t think I have Samba on my machine. If someone could clarify that would be great. I am running Ubuntu Linux. I’ve also noticed a lot of TCP ESTABLISHED connections I don’t recognise. Is this something to investigate further?

Not shown: 993 closed ports PORT      STATE    SERVICE 22/tcp    filtered ssh 53/tcp    open     domain 80/tcp    open     http 139/tcp   open     netbios-ssn 443/tcp   open     https 445/tcp   open     microsoft-ds 49152/tcp open     unknown 

What to do if a player expected much more than DM gave?

I was not the DM in this session, it was my GF, but she does not speak English so I’m here to ask for all of us. We’ve faced an issue that seems we can’t solve.

It was our 2nd game, no one of us ever played before. We played Lost Mine of Phandelver and finally entered a room with a hostage in a cave. Goblins told that they don’t want to fight and proposed a negotiation. We had a jade statuette and one of the PCs told the goblins that we have it (The DM said before that because it cost a lot, the goblins greedily want it).

After that, the goblins asked 20 gold coins and the statuette in exchange for a hostage. Since they had an advantage (3 PCs vs 6 goblins) I told the other players that this is a good price, despite is having to give out almost all our gold, but my friend decided to intimidate them, roleplayed and rolled a natural 20. The DM said that the goblins seemed kinda worried, but since they had a huge advantage, they (only) reduced the price to just the statuette.

After that, my friend was visibly disappointed (and still is) almost to the point where he refuses to play anymore. We were tired at this point since it was our 6th hour or so, and I can understand his mood here.

When we discussed this situation after the game, he explained his point: he had rolled a 20 and this means (in his opinion) that goblins shod have released the hostage without demanding any price because it was a 20. I tried to explain to him that it is up to DM to decide the consequences of any actions players do, and in this situation, the DM decided not to give us more. But the player still thinks that the DM was not right in this situation and a 20 is a 20 and he is ready to even have arguments for this game situation. I tried to convince him that the goblins had a huge advantage here and it was not possible that they give us the hostage without any price, but it seems impossible to convince him. He is negative because of the fact that the DM is the final judge and it is the DM’s responsibility to decide what happens next.

We’ve tried to find some solution on what to do in situations like this and did not come to anything.

What can we do?

At what point is a Lifedrinker Warlock’s expected damage reduced by Sharpshooter/GWM?

At Level 12, a Pact of the Blade Warlock can take the Lifedrinker Eldritch Invocation, which states the following:

When you hit a creature with your pact weapon, the creature takes extra necrotic damage equal to your Charisma modifier (minimum 1).

Assuming a Hexblade Warlock with a 20 in Charisma, this translates to 10 bonus damage per attack. This enormous bonus means that every missed attack results in a significant reduction in damage.

The Sharpshooter and Great Weapon Master feats grant options of the following pattern:

Before you make [an attack] with [a weapon] with which you are proficient, you can choose to take a -5 penalty to the attack roll. If you do so and the attack hits, it deals +10 damage.

At what point is the Warlock’s expected damage per attack reduced by using the optional attack modifier of either the Sharpshooter or Great Weapon Master feat?

Assume a Hexblade, Pact of the Blade Warlock with the following characteristics:

  • At least 12th level
  • Lifedrinker Eldritch Invocation
  • 20 in Charisma
  • Using a pact weapon, either:
    • A longbow
    • A greatsword
  • … with the respective weapon feat:
    • Sharpshooter
    • Great Weapon Master

With the following variables:

  • Enemy AC
  • Attack roll and damage roll bonuses (due to spells, proficiency bonus, magic weapons, etc.)

Why does Avatar Mask not work as expected?

I have 2 layers: The base layer, and an upper body layer. On the upper body layer, I have an avatar mask because I only want to affect the upper body. However, this mask doesn’t work as expected.

Here is what it looks like:

enter image description here

This is what is looks like when the upper body layer has a weight of 0:

enter image description here

And this is with the upper body layer with a weight of 1 and with the Avatar Mask:

enter image description here

As one can see, the lower body is affected. The avatar mask doesn’t seem to have an effect. Is that a bug in Unity, or is there anything I could still check?

Thank you!

What is the expected time complexity of checking equality of two arbitrary strings?

The simple (naive?) answer would be O(n) where n is the length of the shorter string. Because in the worst case you must compare every pair of characters.

So far so good. I think we can all agree that checking equality of two equal length strings requires O(n) runtime.

However many (most?) languages (I’m using Python 3.7) store the lengths of strings to allow for constant time lookups. So in the case of two unequal length strings, you can simply verify len(string_1) != len(string_2) in constant time. You can verify that Python 3 does indeed make this optimization.

Now, if we’re checking the equality of two truly arbitrary strings (of arbitrary length) then it is much more likely (infinitely, I believe) that the strings will be of unequal length than of equal length. Which (statistically) ensures we can nearly always compare them in constant time.

So we can compare two arbitrary strings at O(1) amortized, with a very rare worst-case of O(n). Should we consider strings comparisons then to be O(1) in the same way we consider hash table lookups to be O(1)?

Stack Overflow, and my copy of Cracking the Coding interview cite this operation as O(n).

Cryptoki PKCS11 C_Decrypt returns shorter key (decrypted messaged) than expected

First off let me say I’m fully aware this question can only be answered by the token vendor but I have already contacted them and with the whole COVID situation my hopes of hearing from them soon are not high (nor that I need to, this is just to satisfy my own curiosity). What I’m hoping to get as an answer is maybe somebody with a similar experience.

I have several tokens (smart cards with crypto capabilities based on an MCU from ST Micro., ST19WLxx to be more precise) where I have stored certificates, mostly for authentication and digital signature purposes. But they can also be used for decryption so I decided to give that a try. The original idea was to generate a symmetric key for disk encryption purposes. Then I would use the public key on the card to encrypt it and the private key to decrypt it to unlock access to a partition on my disk.

This is all standard practice and should be pretty straight forward but for completeness, I will guide you through the steps (on Linux; although I also tried with Windows with the same end result):

1) I generated a random symmetric key, 245 bytes long to account for the fact that I will be using RSA-PKCS padding, the only one supported by the card and considering the RSA keys are 2048 bit long:

$   dd if=/dev/urandom of=./symmetric_key bs=1 count=245 

2) I extract the public key from the card, once I got its ID:

$   pkcs11-tool -r --login --id $  KEY_ID --type pubkey --module token_driver.so -o public_key.der 

3) I convert the public key format to pem:

$   openssl rsa -pubin -in pub_key.der -inform DER -outform PEM -out pub_key.pem 

4) I encrypt the symmetric key from step one using my public key:

$   openssl rsautl -inkey ./pub_key.pem -pubin -encrypt -pkcs -in ./symmetryc_key -out ./encrypted_key.pkcs1 

5) And finally, I decrypt with the private key on my card:

$   pkcs11-tool --id $  KEY_ID --decrypt --login -m RSA-PKCS --module token_driver.so --input-file encrypted_key.pkcs1 --output-file decrypted_key 

With that, I should recover the original symmetric_key again on decrypted_key. Unfortunately, this is not what happens. Instead, my decrypted_key is only 102 bytes long.

If I examine the key I can see I’m getting only the last 102 bytes of the original key, the remaining 143 are lost.

This is an example of symmetric_key (sample output from step 1):

00000000  77 1a e4 f3 71 c1 23 c8  0a 47 17 87 d3 c6 ad 31  |w...q.#..G.....1| 00000010  2b 43 94 f9 1f 41 a0 c7  4f 80 5c 00 51 bb 6b b6  |+C...A..O.\.Q.k.| 00000020  a4 4c 87 5b 5c 5c 28 ef  d3 b7 d1 85 a2 3a c0 87  |.L.[\(......:..| 00000030  f1 25 38 b7 b9 28 d7 5f  e4 a1 da 4d 0a 71 f2 85  |.%8..(._...M.q..| 00000040  89 0e bb a4 2b 58 3e 18  90 c6 be 75 22 78 27 d7  |....+X>....u"x'.| 00000050  36 4a 95 74 aa fe e3 c1  d1 f6 02 a0 26 18 28 e2  |6J.t........&.(.| 00000060  14 9c 46 58 ea d1 b6 b6  1f d6 86 f6 9f f7 29 c7  |..FX..........).| 00000070  0e bd 50 8e dd ce 34 65  3f 7a 32 e3 3a 28 4c 3a  |..P...4e?z2.:(L:| 00000080  8d 47 36 9c ab af d0 db  bf d0 db f1 ca 32 be 97  |.G6..........2..| 00000090  62 4e c4 6a 79 b3 1a 3a  2b 2c 11 69 84 9b d5 65  |bN.jy..:+,.i...e| 000000a0  d6 75 b5 00 05 42 c5 8f  cd 82 6a 09 9a 50 07 2b  |.u...B....j..P.+| 000000b0  04 86 0d 15 92 e3 8b cf  fb 97 1c 9e f7 6f 22 51  |.............o"Q| 000000c0  e1 45 00 64 45 3d 4b 38  a6 7f f0 aa 7e 12 bb 26  |.E.dE=K8....~..&| 000000d0  85 91 a4 5c 9e dd 59 6a  f6 85 c2 2b 38 4d 2b c2  |...\..Yj...+8M+.| 000000e0  f1 2f 71 d0 21 46 1b d2  fd 57 03 66 2f b1 c1 0f  |./q.!F...W.f/...| 000000f0  51 53 9d 22 4e                                    |QS."N| 000000f5 

And the corresponding output from decrypting on step 5:

00000000  97 62 4e c4 6a 79 b3 1a  3a 2b 2c 11 69 84 9b d5  |.bN.jy..:+,.i...| 00000010  65 d6 75 b5 00 05 42 c5  8f cd 82 6a 09 9a 50 07  |e.u...B....j..P.| 00000020  2b 04 86 0d 15 92 e3 8b  cf fb 97 1c 9e f7 6f 22  |+.............o"| 00000030  51 e1 45 00 64 45 3d 4b  38 a6 7f f0 aa 7e 12 bb  |Q.E.dE=K8....~..| 00000040  26 85 91 a4 5c 9e dd 59  6a f6 85 c2 2b 38 4d 2b  |&...\..Yj...+8M+| 00000050  c2 f1 2f 71 d0 21 46 1b  d2 fd 57 03 66 2f b1 c1  |../q.!F...W.f/..| 00000060  0f 51 53 9d 22 4e                                 |.QS."N| 00000066 

First thing I thought was: “huh? software/driver issue. But I have access to the driver code and after staring at it and messing with it for quite a long while I am almost completely sure there is nothing wrong with it.

The major clue that makes me think this is a firmware issue (I don’t have access to the code inside the card’s MCU) comes from a very careful examination of the APDU frames that the card exchanges with the host: there are no errors anywhere, I always get the magic 0x9000 everything is fine message from the card and the frame where I receive the decrypted data is short (it’s actually 20 or so bytes longer than 102, but there are headers and a secure channel involved so part of the message is encrypted) and comes announced with the correct number of bytes (SW=0x6179).

I did many more things, like: testing on Windows, trying keys and text messages with different lengths (the decryption works fine up to messages of 102 bytes, longer than that and they get truncated), using different cards with the same hardware and firmware version, using different cards with different hardware and firmware versions (not that dissimilar after all because I got the same problem), getting all debug info from the driver to see if I was getting any hidden errors…

Considering RSA-OAEP is not supported by this card (or at least not documented) and the problems associated with RSA-PKCS I guess it’s best to let this old dog sleep and not try to teach it new tricks.

But as I said: I’m curious, have you ever encounter something like this? Is there something else I can do to be sure this is a firmware issue? I guess in part I refuse to believe something so fundamental has been lurking undetected for so long (this hardware has been in use for many years by a significant amount of people). Maybe there is something wrong with my setup or understanding of the problem after all.