Code Monkey home page Code Monkey logo

libdsm's People

Contributors

alexandre-janniaux avatar andrewjlawrence avatar andreygursky avatar biswa96 avatar chouquette avatar davilla avatar elthariel avatar fkuehne avatar flameeyes avatar iosdevzone avatar janboeye avatar jbkempf avatar johanneskauffmann avatar kxuan avatar lu-zero avatar mstorsjo avatar nikolairuhe avatar olta avatar psilokos avatar reubenhwk avatar robux4 avatar sylverb avatar tguillem avatar thresheek avatar timoliver avatar toco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libdsm's Issues

Fail to make current libdsm-git...

Fail to make current libdsm-git

  CC       contrib/mdx/md4.lo
  CC       contrib/mdx/md5.lo
  CC       contrib/rc4/rc4.lo
asn1Parser -o contrib/spnego/spnego_asn1.c -n spnego_asn1_conf contrib/spnego/spnego.asn1
/bin/bash: asn1Parser: command not found
make[1]: *** [contrib/spnego/spnego_asn1.c] Error 127
make[1]: Leaving directory `/home/jiapei/Downloads/videoprocessing/libdsm'
make: *** [all] Error 2

Cheers
Pei

Incompatibility with TimeCapsule

TimeCapsule is a NAS manufactured by Apple mainly designed to have a network server for Macs to backup their data.

However, it is running an old version of smbx and while libdsm successfully logs in, there is never a directory listing. Reasons are unknown for now.

Missing files in tarball

The tarball lacks abi_version.sh, bootstrap, and package_version.sh. Therefore, linking will fail.

Problem reading SMB OSX Sharing Files, they got corrupted by an extra 00 at the beginning and the lack of last pair

I'm trying libdsm under iOS, with the help of the great and simple wrapper made by @TimOliver (TOSMBClient), and I've found what I think is a bug with, maybe, smb_fread or smb_fopen
(I really hope I'm wrong and this has an easy solution).

When I try to explore and download files from a Mac with SMB OSX sharing enabled, I'm finding two problems. The first one, is that I can not go beyond 1st level. I mean, If I enter in //myMacName/MySharing I can see all the files and folders inside it; However, when I go and select one of those subfolders inside MySharing, like //myMacName/MySharing/folder1, the folder will appear as empty.

The second problem, and more important, is that when I try to download any file stored on /MySharing, it will be corrupted. Opening the downloaded file with an Hex editor, it has an extra 00 at the beginning and it lacks the last pair (compared to the original file). Why is this happening? So far, I only had this problem accessing my Mac, which is password protected (but I have no problems at logging in, since I can see all my personal folders listed).

The think is that, using the same code, if I access to my SMB NAS (raspberrypi), I have no problems at all, and everything works as expected.

Regards,
Sergio

Connecting to accounts with no password set

We received error reports that login fails when connecting to Windows 7 shares where no password was setup for a user account. This is different from guest access ;)

Needs to be investigated.

stat: difference between error and non-existing file/directory

Hi there,

smb_fstat returns NULL in case of an error (like a timeout) and also NULL if the file/directory does not exist. Is there a way to differentiate between an error and a file not existing (without listing the parent directory)?

BTW, nt_status on the session is success after the operation even in case of a timeout.

I also tried smb_find in the vain hope that it would return an empty list, if the file doesn't exist and NULL in case of an error, but found that it returns NULL in both cases.

As a side note: The timeout is awfully long (something like 3 minutes). Is there a way to set it? Also (sometimes?) when the socket is broken, my application dies of sigpipe. While I can handle that, I still wonder whether this is an intended behaviour.

OSX smb_fopen with "/" at the beginning of the file path

hello,

if i call the smb_fopen method with file path of this form: "/test.txt" in read mode on OS X share, i receive a -2 error code (Failed to open file: /test.txt)

failed code sample:
const chat * fileNameAndPath = "/test.txt";
int openFileResult = smb_fopen(smbSession, shareID, fileNameAndPath, SMB_MOD_RO, &fileDescriptor);

but if i remove the first "/" and call it like this:

success code sample:
const chat * fileNameAndPath = "test.txt";
int openFileResult = smb_fopen(smbSession, shareID, fileNameAndPath, SMB_MOD_RO, &fileDescriptor);

if i try this on a windows share it will work both ways!

my end code simply strip the first "/" from all calls (since OS X and Windows can handle it),

i would love it if the bug was found and fixed (or that someone will prove me wrong),

Thanks,
Shay.BC.

smb_fstat doesn't work for directories

On a directory, smb_fstat seems to always return NULL.

Current workaround:

smb_stat stat = smb_fstat(s, tid, path);
if (stat == NULL) {
    smb_stat_list stats = smb_find(s, tid, path);
    if (stats != NULL) {
        size_t n = smb_stat_list_count(stats);
        if (n == 1) {
            stat = smb_stat_list_at(stats, 0);
        }
    }
}

Unless of course, I misunderstood the api...

Can't build on OS X for iOS

Hi,

I'm having some trouble cross compiling libdsm for arm (iOS). My first thought was that it was a generic problem with what I was doing, rather than something directly related to libdsm, but now I'm wondering if it's something libdsm specific. I posted the details on stackoverflow. If VNC for iOS uses this library, though, then it must work. Does anyone know what might be wrong, and is it my problem, of a libdsm issue?

Thanks.

Failed to build the lib on ubuntu14.04

Key logs:

In file included from src/netbios_ns.c:57:0:
./compat/compat.h:39:5: error: expected identifier before numeric constant
./compat/compat.h:43:3: error: conflicting types for ‘clockid_t’
/usr/include/time.h:92:21: note: previous declaration of ‘clockid_t’ was here
./compat/compat.h:44:5: error: conflicting types for ‘clock_gettime’
/usr/include/time.h:336:12: note: previous declaration of ‘clock_gettime’ was here
src/netbios_ns.c: In function ‘netbios_ns_abort’:
src/netbios_ns.c:627:10: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
make[1]: *** [src/netbios_ns.lo] Error 1
make[1]: Leaving directory `/home/dxy/d120/vlc/contrib/src/libdsm-0.0.5/mastar-git/libdsm'
make: *** [all] Error 2

smb_find_parse crashes with EXC_BAD_ACCESS on iOS 7.1 with smb_tr2_find2_entry with incorrect fields

So I've been testing running this using a sample iOS application that is simply connecting to a share and listing all files in the folder. The entry that seems to cause the issue is not necessarily the same file each time and searching for the individual file itself works. Below are the examples of entries with problems with the raw hex bytes parsed out for each field:

next_entry: 88000000
index: 00000000
created: 31B95113CC9ECF01
accessed: 35462814CC9ECF01
written: 144BF916CC9ECF01
changed: 893D702BCC9ECF01
size: B2360A0000000000
alloc_size: 00400A0000000000
attr: 20000000
name_len: 2A000000
ea_list_len: 00001800
short_name_len: 50
reserved: 00
short_name[24]: 450052004600450043007E0031002E005A00490050007000
name[]: 6500720066006500630074005F006400610072006B005F0031002E00310038002E007A0069007000B000

The problem with this one is that there are 2 bytes missing that should be zeroes in the ea_list_len field. This then causes offset issues beyond this where short name len is 0x50 which is a obviously way too large and the name field has the first letter of the file name truncated as due to the offset problem it is in the short name field. The "B000" at the end of the name field should be the first 2 bytes of the next entry field of the following entry which is the one that ultimately causes the crash.

next_entry: 00000000
index: 00003454
created: 24EF19CACF013454
accessed: 24EF19CACF0132A5
written: 609CEBB2CC0166C9
changed: 24EF19CACF016676
size: 0600000000000080
alloc_size: 0600000000002000
attr: 00004C00
name_len: 00000000
ea_list_len: 00001800
short_name_len: 52
reserved: 00
short_name[24]: 4500410044004F0052007E0031002E005200410052005200
name[]: 65006100640020004F007200200044006900650020004F0041005600200056006F006C0020003100200056003100200054004F0020005600320020004600490058002E00720061007200000000000000

The next entry should not be NULL as there are more entries after this one in the payload and many of the other fields are just blatantly wrong.

From another attempt at listing the files this entry caused a crash:

next_entry: B0000000
index: 00000000
created: 24EF19CACF013454
accessed: 24EF19CACF0132A5
written: 609CEBB2CC0166C9
changed: 24EF19CACF016676
size: 6676060000000000
alloc_size: 0600000000002000
attr: 00004C00
name_len: 00000000
ea_list_len: 00001800
short_name_len: 52
reserved: 00
short_name[24]: 4500410044004F0052007E0031002E005200410052005200
name[]: 65006100640020004F007200200044006900650020004F0041005600200056006F006C0020003100200056003100200054004F0020005600320020004600490058002E007200610072000000000000007000

Most of the fields look correct until the alloc_size field which is missing 2 bytes which causes the alloc size field to be ridiculously large compared to the size field and then causes offset issues for the rest of the entry. If I search specifically for this file the entry there are no issues and the entry fields look like the following:

next_entry: 00000000
index: 00000000
created: 24EF19CACF013454
accessed: 24EF19CACF0132A5
written: 609CEBB2CC0166C9
changed: 24EF19CACF016676
size: 6676060000000000
alloc_size: 0080060000000000
attr: 20000000
name_len: 4C000000
ea_list_len: 00000000
short_name_len: 18
reserved: 00
short_name[24]: 52004500410044004F0052007E0031002E00520041005200
name[]: 520065006100640020004F007200200044006900650020004F0041005600200056006F006C0020003100200056003100200054004F0020005600320020004600490058002E00720061007200000000000000

No details about failure reasons at interface

Most functions are just giving a success/fail status but there is no way to know the reason why it fails.
In my file/folder delete & folder creation functions, I use the returned value to tell the error code but I'm not sure it's the best way to achieve this can't be generalized to all functions ...
I guess that passing an optional "error" pointer in interface functions to return error code would be a better way to do.
Before starting any coding, I just wanted your point of view !

Problems when downloading big files

I have a problem that happens when downloading files ! I think that the problem is only occurring in rare cases so I'm only able to get it on big files ... I've done several tests on a 9GB file and I've met 2 kinds of problems :

  • File downloads fine but data are corrupted at a given point (could be after 1GB or later)
  • smb_session_recv_msg exists with 0 in smb_fread function

Does anyone have any idea of what could happen ? I'm running libdsm on MacOS X but it seems to also happen on iOS/tvOS :I've done this test because I'm using libdsm in libvlc for iOS, and for some reason the playback of videos over smb is always crashing after few minutes ...

License

Hi, I know it's a bit off-topic, because some of the following is a general licensing issue. Please point me in the right direction, if this is the wrong place for this question.

I have an Objective-C project, which creates a dynamic library that wraps libdsm. To be able to use this library in a commercial setting, I assume that I have the following options

a) Make my project available under the LGPL (sufficient because the library is dynamic), or
b) Obtain a proprietary license from VideoLAN

Is that correct?

Now, if I go for option a), but want to make my library available to people who find the LGPL too restrictive, I assume I can put it under dual-license (e.g. MIT/LGPL). If people however, choose to use my library under the MIT License, I also assume that they require a proprietary license from VideoLAN.

Is that also correct?

Support building with OpenBSD

Trying to build libdsm on OpenBSD it is failing at the moment..

cc -std=gnu99 -DHAVE_CONFIG_H -I. -O0 -g3 -I./contrib -I./include -I./compat -I/usr/local/include -O2 -pipe -Wall -Wsign-compare -Wextra -I/usr/local/include -pthread -MT src/smb_buffer.lo -MD -MP -MF src/.deps/smb_buffer.Tpo -c src/smb_buffer.c -fPIC -DPIC -o src/.libs/smb_buffer.o
src/smb_buffer.c:31:20: error: alloca.h: No such file or directory

Fix leaks

Valgrind is very unhappy, fix this

App Crash when upload/write file to shared folder through iOS.

Hi,

Thanks for the great lib, I'm trying to upload files with my iOS application and i have done some research on how to use smb_fwrite and finally I'm able to use it. But most of the times its crashing at

                        **__length = smb_fwrite(_uploadSession, _fileID, _buffer, _read_length);_**

and the buffer size I'm giving as 65535
please help me on this, how can i handle this?

Thanks in advance .

Narendra.

SIGPIPE

Why does not disable the socket sigpipe, this will result in many platform process exit.

How to create new smb file on server ?

Hi tguillem

Thanks you very much about awesome library.

I already can upload data from IOS device to an exist file on smb server using smb_fwrite().
But I don't know how to create a new file on smb server from IOS device, and upload data to it.

Can you show me how to do that please?
Some thing like smb_file_create() as smb_dir_create().

Compiling for all iOS architectures

Hi guys!

I'm really interested in this library. SMB support has been something I've been wanting to add to my iOS app for a long time, and this library looks like the nicest, most license-friendly one out there right now. :)

Sorry about reviving this old discussion (I noticed it was already mentioned in a few pull requests), but I was hoping to get some help in being able to compile this library for a shipping iOS app.

For reference, I saw captainadamo's CLI script in a (now closed) issue here:

export SDKPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk
export MIN_IOS_VERSION=7.1
export ARCH=armv7
export HOST=$ARCH-apple-darwin
export CFLAGS=-arch $ARCH -isysroot $SDKPATH -miphoneos-version-min=MIN_IOS_VERSION
export LDFLAGS=-isysroot $SDKPATH

# Compiling libtasn1:

export ARM_LIBTASN_INSTALL_PATH={path you want}
./configure --host=$HOST --prefix=$ARM_LIBTASN_INSTALL_PATH
make && make install

# Compiling libdsm:

export CFLAGS+=-I$SDKPATH/usr/include
export LDFLAGS+=-L$SDKPATH/usr/lib -liconv
export LIBDSM_INSTALL_PATH={path you want}
export TASN1_CFLAGS=-I$ARM_LIBTASN_INSTALL_PATH/include
export TASN1_LIBS=-L$ARM_LIBTASN_INSTALL_PATH/lib -ltasn1
./bootstrap
./configure --host=$HOST --prefix=$LIBDSM_INSTALL_PATH
make && make install

I tried running this script on my Mac, and it produced a "libdsm.a" static library file as expected, but the file only contained an x86_64 architecture slice. Is that correct, or am I doing something wrong? Additionally, armv7 aside, is it possible to compile slices for armv7s and arm64 as well?

If I can get this working, I'd be more than happy to create a wiki page or addition to the README in helping to explain this process in a more formal capacity.

Thanks a lot for your time! :)

Crash with multiple downloads at the same time

Hi,

I am trying to download multiple files from SMB to iPad's app Sandbox.

From code wise, I get SIGABRT at smb_session_login while checking connection before file download gets start.

Sometimes, smb_tree_connect is not creating treeID and I get SIGABRT at smb_fopen while opening file.

I faced same errors even if I create a session for each download task.

Does this library not allow multiple downloads?
Please suggest me here.

Support big-endian

Right now libdsm isn't doing any clean parsing of smb messages, it justs cast data received to packed c structures.

This basically means there is no way we can work this way on system with the other endianness ...

Build asn1 data in make dist

As stated by @mstorsjo,

btw, if you are considering building release tarballs at some point, it might be nice to run the asn1Parse step as part of "make dist" - otherwise when crosscompiling (such as part of the vlc contrib system), you'd need to build libtasn1 twice, once for the host (to get the asn1Parse binary) and once for the actual target

I'm not very familiar with autotools, but I think this can be done via "dist-hook" somehow

Netbios reverse lookup & OSX

OSX doesn't provides the file server entry all the time, so we need to return another name than the <20> if it isn't there

smb_session_is_guest return wrong after logined

After call smb_session_login which return 0, the smb_session_is_guest return -1 as Not Logged.

After view the code, I found the smb_session_login_ntlm function not set session->logged variable when login success.

Issue discovered by asan

I compiled the dsm example with clang address sanitizer enabled.
Trying to connect to a smbx-276.92.2 server I run into following issue:

$ dsm HOME Guest "" Movies "test"
netbios_ns_send_name_query, name query sent for '*'.
netbios_ns_resolve, received a reply for 'HOME', ip: 0x7DB2A8C0!
HOME's IP address is : 192.168.178.125
Server is supporting extended security
Successfully connected to HOME
init_asn1: ASN.1 parser initialized
Server challenge is 0x52f3fef05afc590
=================================================================
==67774==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff55820808 at pc 0x00010a48b9ba bp 0x7fff55820390 sp 0x7fff5581fb48
READ of size 16 at 0x7fff55820808 thread T0
    #0 0x10a48b9b9 in __asan_memcpy (/Applications/Xcode-7.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/7.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib+0x399b9)
    #1 0x10a3f5346 in HMAC_MD5 hmac_md5.c:54
    #2 0x10a40ca10 in smb_ntlm2_session_key smb_ntlm.c:273
    #3 0x10a40d97c in smb_ntlmssp_response smb_ntlm.c:341
    #4 0x10a407ea3 in auth smb_spnego.c:263
    #5 0x10a4053cc in smb_session_login_spnego smb_spnego.c:345
    #6 0x10a411488 in smb_session_login smb_session.c:319
    #7 0x10a3df861 in main dsm.c:162
    #8 0x7fff8f8f05ac in start (/usr/lib/system/libdyld.dylib+0x35ac)
    #9 0x5  (<unknown module>)

Address 0x7fff55820808 is located in stack of thread T0 at offset 40 in frame
    #0 0x10a40c87f in smb_ntlm2_session_key smb_ntlm.c:269

  This frame has 3 object(s):
    [32, 40) '' <== Memory access at offset 40 overflows this variable
    [64, 322) 'rc4'
    [400, 416) 'hmac_ntlm2'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow ??:0 __asan_memcpy
Shadow bytes around the buggy address:
  0x1fffeab040b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 f3 f3 f3
  0x1fffeab040c0: f3 f3 f3 f3 f3 f3 f3 f3 00 00 00 00 00 00 00 00
  0x1fffeab040d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeab040e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeab040f0: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
=>0x1fffeab04100: 00[f2]f2 f2 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeab04110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeab04120: 00 00 00 00 02 f2 f2 f2 f2 f2 f2 f2 f2 f2 00 00
  0x1fffeab04130: f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeab04140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffeab04150: f1 f1 f1 f1 00 f2 f2 f2 00 00 f2 f2 00 00 f2 f2
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==67774==ABORTING
Abort trap: 6

Having a look at the code yields that smb_ntlm.c:273 uses the address hash_v2 as a parameter to HMAC_MD5 which is already a pointer to a uint8_t[64] array:

void        smb_ntlm2_session_key(smb_ntlmh *hash_v2, void *ntlm2,
                                  smb_ntlmh *xkey, smb_ntlmh *xkey_crypt)
{
//[...]
HMAC_MD5(&hash_v2, 16, ntlm2, 16, &hmac_ntlm2);

So if we resolve the typedef uint8_t *** is passed to MAC_MD5(

Shouldn't it rather be

HMAC_MD5(*hash_v2, 16, ntlm2, 16, &hmac_ntlm2);

to dereference the pointer to the array pointer so the MD5 created from the contents of the array?
I we resolve the typedef we would pass uint8* to the function, which would make more sense to me.

When I try to run dsm with this change authentication fails but asan don't complain.

Add timeout handling in case of smb_fread

When you create a download task from network it may work infinitely if the network connection was lost. It would be good to add the timeout/network lost error, after which the task would fail.

Thanks,
Naren

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.