Skip to content

u/visualq

In this archive from Sep 2010 to Nov 2026

3
posts
56
comments
0
media
272
score

We used FFI with liboqc to provide PQC, eventually we wrote an extension for this lib. No idea how long we'd still need this with OpenSSL 3.5+ supporting PQC. Not much of a heaven/horror story but I can imagine that it is going to be annoying when the headers change

1 points

It was indeed a linker problem, even thought the ./configure said it found libsodium-1.0.13. I still had the vendor library installed (1.0.8-5) (/usr/lib). I uninstalled that one first, reinstalled 1.0.13 (/usr/local/lib) and it worked properly.

Thanks for the help

2 points

Thank you!

I restarted the build process and reverted back to OpenSSL 1.0.1f. Without the --with-sodium flag the build runs just fine.

When I try the --with-sodium and libsodium-1.0.13 installed it gives me:

In function `zm_startup_sodium':
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:464: undefined reference to `crypto_pwhash_opslimit_interactive'
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:466: undefined reference to `crypto_pwhash_memlimit_interactive'
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:468: undefined reference to `crypto_pwhash_opslimit_moderate'
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:470: undefined reference to `crypto_pwhash_memlimit_moderate'
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:472: undefined reference to `crypto_pwhash_opslimit_sensitive'
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:474: undefined reference to `crypto_pwhash_memlimit_sensitive'
ext/sodium/.libs/libsodium.o: In function `zif_sodium_crypto_pwhash':
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:1831: undefined reference to `crypto_pwhash'
ext/sodium/.libs/libsodium.o: In function `zif_sodium_crypto_pwhash_str':
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:1875: undefined reference to `crypto_pwhash_str'
ext/sodium/.libs/libsodium.o: In function `zif_sodium_crypto_aead_xchacha20poly1305_ietf_encrypt':
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:2362: undefined reference to `crypto_aead_xchacha20poly1305_ietf_encrypt'
ext/sodium/.libs/libsodium.o: In function `zif_sodium_crypto_aead_xchacha20poly1305_ietf_decrypt':
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:2431: undefined reference to `crypto_aead_xchacha20poly1305_ietf_decrypt'
ext/sodium/.libs/libsodium.o: In function `zif_sodium_crypto_pwhash_str_verify':
/usr/local/src/php-7.2.0beta2/ext/sodium/libsodium.c:1912: undefined reference to `crypto_pwhash_str_verify'
collect2: error: ld returned 1 exit status
Makefile:311: recipe for target 'sapi/fpm/php-fpm' failed
make: *** [sapi/fpm/php-fpm] Error 1
1 points

Anyone managed to compile this on Ubuntu 16.04? I'm running into way to many SSL problems if I enable libsodium. Trying to compile with a newer version of libsodium and openssl works for libsodium but it starts giving problems elsewere regarding other tools being build with a different Openssl version.

/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libc-client.a(osdep.o): undefined reference to symbol 'SSL_CTX_set_tmp_rsa_callback@@OPENSSL_1.0.0' //lib/x86_64-linux-gnu/libssl.so.1.0.0: error adding symbols: DSO missing from command line

Anyone got a proper build flow?

1 points

No, if the GET parameter contains a number and the query treats it as such, mysqli_real_escape_string wont do you any good.

Example:

$my_value = mysqli_real_escape_string($_GET['value']);
mysqli_query($link, "DELETE FROM table WHERE user_id = $my_value");

if the get value would be: 1 OR 1=1 it would still delete everything.

Now if all your queries look like:

"SELECT * FROM table WHERE '$my_value'"

, note the quotes around $my_value I believe it would not be a problem (using mysqli_real_escape_string that is ofcourse)

Anyway I suggest you get your prepared statements up and running asap..

3 points

Still get the PDO exception:

[Mon Oct 08 12:20:49 2012] [error] [client 127.0.0.1] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.' in /var/www/x/xhprof/classes/data.php:257\nStack trace:\n#0 /var/www/x/xhprof/classes/data.php(257): PDOStatement->execute()\n#1 /var/www/x/inc/append.php(25): ay\xhprof\Data->save(Array)\n#2 [internal function]: {closure}()\n#3 {main}\n thrown in /var/www/x/xhprof/classes/data.php on line 257

1 points

Got a bunch of errors,

[Mon Oct 08 11:33:41 2012] [error] [client 127.0.0.1] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.' in /var/www/x/xhprof/classes/data.php:255\nStack trace:\n#0 /var/www/x/xhprof/classes/data.php(255): PDOStatement->execute()\n#1 /var/www/x/inc/append.php(25): XHProf\Data->save(Array)\n#2 [internal function]: {closure}()\n#3 {main}\n thrown in /var/www/x/xhprof/classes/data.php on line 255

changed the following in append.php:

$xhprof_data_obj = new XHProf\Data($config['pdo']);

to

$xhprof_data_obj = new \ay\XHProf\Data($config['pdo']);

reason for this is the following error:

[Mon Oct 08 11:30:12 2012] [error] [client 127.0.0.1] PHP Fatal error: Class 'XHProf\Data' not found in /var/www/x/inc/append.php on line 24

Haven't looked into the database problem yet

0 points

Slightly modified to make it work 'properly' with 2007-, or -3021. Performancewise it could be better ;)

function parseYears($y, $asKeys = false)
{
    if(!is_string($y))
        throw new Exception("year list is not a string");        
    
    $y = preg_replace("/[\s]/", '', $y);        

    if( preg_match("/[^0-9,-\s]/", $y) )
        throw new Exception("year list contains invalid data");

    $yearList = array();

    //split on commas first, then dash
    $years = explode(",", $y);
    while($year = array_pop($years))
    {
        $left = 0;
        $right = 0;
        $result = sscanf($year, '%i-%i', $left, $right);
        switch($result)
        {
            case 2:
                $yearList = array_merge($yearList, range($left, $right));	
            break;
	
            default:
            case 1:
                $yearList[] = (int) $left;
            break;
        }
    }
    sort($yearList);
    $yearList = array_unique($yearList);

    return $asKeys ? array_flip($yearList) : $yearList;
}
1 points

Something in the lines of:

function getRandomString($len)
{
    static $set = 'abcdefghijklmnopqrstuvwxyz.....etc';
    $charset = str_shuffle($set);
    return substr($charset, 0, max((int) $len, 5));
}

edit: The problem with this function is that the requested length can only be as long as the charset. The second problem is that you never get duplicate characters unless there are duplicates in the charset. The upside is: it's much faster than the other code snippets.

-2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.