~ubuntu-branches/ubuntu/oneiric/samba/oneiric-security

« back to all changes in this revision

Viewing changes to source3/lib/util_str.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-03-10 10:03:01 UTC
  • mfrom: (0.39.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110310100301-jfjg41wv0iq05zj4
Tags: 2:3.5.8~dfsg-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access. 
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/mksmbpasswd.awk:
    - Do not add user with UID less than 1000 to smbpasswd
  + debian/control:
    - Make libwbclient0 replace/conflict with hardy's likewise-open.
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
    - Add cuups breaks to push the package to aslo upgrade cups (LP: #639768)
  + debian/rules:
    - enable "native" PIE hardening.
    - Add BIND_NOW to maximize benefit of RELRO hardening.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
    - Don't ship the /etc/network/if-up.d file.
  + debian/samba.postinst: 
    - Fixed bashism.
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/samba.logrotate: Make it upstart compatible
  + debian/samba-common.dhcp: Fix typo to get a proper parsing in
    /etc/samba/dhcp.
  + Dropped:
    - debian/patches/fix-windows7-print-connection.patch: Merged upstream.
    - debian/patches/security-CVE-2011-0719.patch: Merged upstream. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1454
1454
}
1455
1455
 
1456
1456
/**
1457
 
 Count the number of UCS2 characters in a string. Normally this will
1458
 
 be the same as the number of bytes in a string for single byte strings,
1459
 
 but will be different for multibyte.
1460
 
**/
1461
 
 
1462
 
size_t strlen_m(const char *s)
 
1457
 * Calculate the number of units (8 or 16-bit, depending on the
 
1458
 * destination charset), that would be needed to convert the input
 
1459
 * string which is expected to be in in CH_UNIX encoding to the
 
1460
 * destination charset (which should be a unicode charset).
 
1461
 */
 
1462
size_t strlen_m_ext(const char *s, const charset_t dst_charset)
1463
1463
{
1464
1464
        size_t count = 0;
1465
1465
 
1479
1479
        while (*s) {
1480
1480
                size_t c_size;
1481
1481
                codepoint_t c = next_codepoint(s, &c_size);
1482
 
                if (c < 0x10000) {
1483
 
                        /* Unicode char fits into 16 bits. */
 
1482
                s += c_size;
 
1483
 
 
1484
                switch(dst_charset) {
 
1485
                case CH_UTF16LE:
 
1486
                case CH_UTF16BE:
 
1487
                case CH_UTF16MUNGED:
 
1488
                        if (c < 0x10000) {
 
1489
                                /* Unicode char fits into 16 bits. */
 
1490
                                count += 1;
 
1491
                        } else {
 
1492
                                /* Double-width unicode char - 32 bits. */
 
1493
                                count += 2;
 
1494
                        }
 
1495
                        break;
 
1496
                case CH_UTF8:
 
1497
                        /*
 
1498
                         * this only checks ranges, and does not
 
1499
                         * check for invalid codepoints
 
1500
                         */
 
1501
                        if (c < 0x80) {
 
1502
                                count += 1;
 
1503
                        } else if (c < 0x800) {
 
1504
                                count += 2;
 
1505
                        } else if (c < 0x1000) {
 
1506
                                count += 3;
 
1507
                        } else {
 
1508
                                count += 4;
 
1509
                        }
 
1510
                        break;
 
1511
                default:
 
1512
                        /*
 
1513
                         * non-unicode encoding:
 
1514
                         * assume that each codepoint fits into
 
1515
                         * one unit in the destination encoding.
 
1516
                         */
1484
1517
                        count += 1;
1485
 
                } else {
1486
 
                        /* Double-width unicode char - 32 bits. */
1487
 
                        count += 2;
1488
1518
                }
1489
 
                s += c_size;
1490
1519
        }
1491
1520
 
1492
1521
        return count;
1493
1522
}
1494
1523
 
 
1524
size_t strlen_m_ext_term(const char *s, const charset_t dst_charset)
 
1525
{
 
1526
        if (!s) {
 
1527
                return 0;
 
1528
        }
 
1529
        return strlen_m_ext(s, dst_charset) + 1;
 
1530
}
 
1531
 
 
1532
/**
 
1533
 Count the number of UCS2 characters in a string. Normally this will
 
1534
 be the same as the number of bytes in a string for single byte strings,
 
1535
 but will be different for multibyte.
 
1536
**/
 
1537
 
 
1538
size_t strlen_m(const char *s)
 
1539
{
 
1540
        return strlen_m_ext(s, CH_UTF16LE);
 
1541
}
 
1542
 
1495
1543
/**
1496
1544
 Count the number of UCS2 characters in a string including the null
1497
1545
 terminator.