Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UBSAN reported by Prof. Ripley #1

Closed
bobjansen opened this issue Apr 11, 2022 · 0 comments
Closed

Fix UBSAN reported by Prof. Ripley #1

bobjansen opened this issue Apr 11, 2022 · 0 comments

Comments

@bobjansen
Copy link
Owner

bobjansen commented Apr 11, 2022

UBSAN has recently been found, as described here and quoted below for reference:

R Under development (unstable) (2022-04-07 r82109) -- "Unsuffered Consequences"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> pkgname <- "scrypt"
> source(file.path(R.home("share"), "R", "examples-header.R"))
> options(warn = 1)
> library('scrypt')
> 
> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
> base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv')
> cleanEx()
> nameEx("hashPassword")
> ### * hashPassword
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: hashPassword
> ### Title: Hash a password
> ### Aliases: hashPassword
> 
> ### ** Examples
> 
> # Hash password using default parameters
> hashPassword('passw0rd')
scrypt-1.1.6/lib/crypto/sha256.c:254:24: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
    #0 0x7f40b5fa730f in scrypt_SHA256_Update /data/gannet/ripley/R/packages/tests-clang-SAN/scrypt/src/scrypt-1.1.6/lib/crypto/sha256.c:254:3
    #1 0x7f40b5fc52ab in scrypt_HMAC_SHA256_Update /data/gannet/ripley/R/packages/tests-clang-SAN/scrypt/src/scrypt-1.1.6/lib/crypto/sha256.c:335:2
    #2 0x7f40b5fc52ab in PBKDF2_SHA256 /data/gannet/ripley/R/packages/tests-clang-SAN/scrypt/src/scrypt-1.1.6/lib/crypto/sha256.c:377:2
    #3 0x7f40b5fc5b4b in crypto_scrypt /data/gannet/ripley/R/packages/tests-clang-SAN/scrypt/src/scrypt-1.1.6/lib/crypto/crypto_scrypt-ref.c:258:2
    #4 0x7f40b5ff3bfd in getcpuperf(double*) /data/gannet/ripley/R/packages/tests-clang-SAN/scrypt/src/util.cpp:145:13
    #5 0x7f40b5fede5d in (anonymous namespace)::getparams(double, double, int*, unsigned int*, unsigned int*) /data/gannet/ripley/R/packages/tests-clang-SAN/scrypt/src/scrypt.cpp:49:15
    #6 0x7f40b5fed46f in hashPassword(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, double, double) /data/gannet/ripley/R/packages/tests-clang-SAN/scrypt/src/scrypt.cpp:129:15
    #7 0x7f40b5fcb821 in _scrypt_hashPassword /data/gannet/ripley/R/packages/tests-clang-SAN/scrypt/src/RcppExports.cpp:17:34
    #8 0x6e6372 in R_doDotCall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:607:17
    #9 0x84bf7e in bcEval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:7692:21
    #10 0x82d14e in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:748:8
    #11 0x8959c3 in R_execClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c
    #12 0x89166f in Rf_applyClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1844:16
    #13 0x82db88 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:871:12
    #14 0x95c7d6 in Rf_ReplIteration /data/gannet/ripley/R/svn/R-devel/src/main/main.c:264:2
    #15 0x95fd30 in R_ReplConsole /data/gannet/ripley/R/svn/R-devel/src/main/main.c:316:11
    #16 0x95fb39 in run_Rmainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1137:5
    #17 0x95fe72 in Rf_mainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1144:5
    #18 0x4f30ba in main /data/gannet/ripley/R/svn/R-devel/src/main/Rmain.c:29:5
    #19 0x7f40c5cc2b74 in __libc_start_main (/lib64/libc.so.6+0x27b74) (BuildId: 08df60634339b221bb854d4e10b7278cafde70c4)
    #20 0x43231d in _start (/data/gannet/ripley/R/R-clang-SAN/bin/exec/R+0x43231d)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior scrypt-1.1.6/lib/crypto/sha256.c:254:24 in 
[1] "c2NyeXB0AA0AAAAIAAAAAVYLCibsie4sa+qsjl+/M91oAQHaF/cbdCXgkKVHbqjy3Oa6wR0drHouY8rxnjYgDolqGcDhAEE4Wrg7G0geuC4M/xoaVRHhX+fWnzIUTpGj"
> 
> # Hash password with custom parameters
> hashPassword('passw0rd', maxmem=0.25, maxtime=1.0)
[1] "c2NyeXB0AA0AAAAIAAAAAWpuqY05OCSG48XLNnakPpaBjkLwviKQ/JAI85CmY5hgtUR4FBVx9ac1bf/cvgA8tZWL7cpo40MRpMpWodBaEnTK1VqLxdi9v0VUGW4EW6At"
> 
> 
> 
> cleanEx()
> nameEx("verifyPassword")
> ### * verifyPassword
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: verifyPassword
> ### Title: Verify a hashed password
> ### Aliases: verifyPassword
> 
> ### ** Examples
> 
> # Hash password using default parameters
> hashed <- hashPassword("password")
> 
> # verify invalid password
> verifyPassword(hashed, "bad password");
[1] FALSE
> 
> # verify correct password
> verifyPassword(hashed, "password")
[1] TRUE
> 
> 
> 
> ### * <FOOTER>
> ###
> cleanEx()
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
Time elapsed:  4.176 0.134 12.129 0 0 
> grDevices::dev.off()
null device 
          1 
> ###
> ### Local variables: ***
> ### mode: outline-minor ***
> ### outline-regexp: "\\(> \\)?### [*]+" ***
> ### End: ***
> quit('no')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant