Ignore:
Timestamp:
Mar 11, 2009, 9:14:55 AM (16 years ago)
Author:
Paul Smedley
Message:

Add 'missing' 3.0.34 diffs

Location:
branches/samba-3.0/source/lib
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/lib/charcnv.c

    r124 r165  
    1 /*
     1/* 
    22   Unix SMB/CIFS implementation.
    33   Character set conversion Extensions
     
    66   Copyright (C) Simo Sorce 2001
    77   Copyright (C) Martin Pool 2003
    8 
     8   
    99   This program is free software; you can redistribute it and/or modify
    1010   it under the terms of the GNU General Public License as published by
    1111   the Free Software Foundation; either version 2 of the License, or
    1212   (at your option) any later version.
    13 
     13   
    1414   This program is distributed in the hope that it will be useful,
    1515   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1717   GNU General Public License for more details.
    18 
     18   
    1919   You should have received a copy of the GNU General Public License
    2020   along with this program; if not, write to the Free Software
     
    3535 *
    3636 * @brief Character-set conversion routines built on our iconv.
    37  *
     37 * 
    3838 * @note Samba's internal character set (at least in the 3.0 series)
    3939 * is always the same as the one for the Unix filesystem.  It is
     
    145145                        const char *n2 = charset_name((charset_t)c2);
    146146                        if (conv_handles[c1][c2] &&
    147                                 strcmp(n1, conv_handles[c1][c2]->from_name) == 0 &&
    148                                 strcmp(n2, conv_handles[c1][c2]->to_name) == 0)
     147                            strcmp(n1, conv_handles[c1][c2]->from_name) == 0 &&
     148                            strcmp(n2, conv_handles[c1][c2]->to_name) == 0)
    149149                                continue;
    150150
     
    202202
    203203static size_t convert_string_internal(charset_t from, charset_t to,
    204                           void const *src, size_t srclen,
    205                           void *dest, size_t destlen, BOOL allow_bad_conv)
     204                      void const *src, size_t srclen,
     205                      void *dest, size_t destlen, BOOL allow_bad_conv)
    206206{
    207207        size_t i_len, o_len;
     
    237237        retval = smb_iconv(descriptor, &inbuf, &i_len, &outbuf, &o_len);
    238238        if(retval==(size_t)-1) {
    239                         const char *reason="unknown error";
     239                const char *reason="unknown error";
    240240                switch(errno) {
    241241                        case EINVAL:
     
    247247                                break;
    248248                        case E2BIG:
    249                                 reason="No more room";
     249                                reason="No more room"; 
    250250                                if (!conv_silent) {
    251251                                        if (from == CH_UNIX) {
     
    278278 use_as_is:
    279279
    280         /*
     280        /* 
    281281         * Conversion not supported. This is actually an error, but there are so
    282282         * many misconfigured iconv systems and smb.conf's out there we can't just
     
    376376
    377377size_t convert_string(charset_t from, charset_t to,
    378                           void const *src, size_t srclen,
    379                           void *dest, size_t destlen, BOOL allow_bad_conv)
     378                      void const *src, size_t srclen,
     379                      void *dest, size_t destlen, BOOL allow_bad_conv)
    380380{
    381381        /*
     
    518518 *
    519519 * Ensure the srclen contains the terminating zero.
    520  *
     520 * 
    521521 * I hate the goto's in this function. It's embarressing.....
    522522 * There has to be a cleaner way to do this. JRA.
     
    524524
    525525size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
    526                                    void const *src, size_t srclen, void *dst, BOOL allow_bad_conv)
     526                               void const *src, size_t srclen, void *dst, BOOL allow_bad_conv)
    527527{
    528528        size_t i_len, o_len, destlen = (srclen * 3) / 2;
     
    584584                           &inbuf, &i_len,
    585585                           &outbuf, &o_len);
    586         if(retval == (size_t)-1)                {
    587                         const char *reason="unknown error";
     586        if(retval == (size_t)-1)                {
     587                const char *reason="unknown error";
    588588                switch(errno) {
    589589                        case EINVAL:
     
    595595                                break;
    596596                        case E2BIG:
    597                                 goto convert;
     597                                goto convert;           
    598598                        case EILSEQ:
    599599                                reason="Illegal multibyte sequence";
     
    630630        ob[destlen] = '\0';
    631631        ob[destlen+1] = '\0';
     632
    632633        return destlen;
    633634
    634635 use_as_is:
    635636
    636         /*
     637        /* 
    637638         * Conversion not supported. This is actually an error, but there are so
    638639         * many misconfigured iconv systems and smb.conf's out there we can't just
     
    720721 *
    721722 * @param srclen length of source buffer.
    722  * @param dest always set at least to NULL
     723 * @param dest always set at least to NULL 
    723724 * @note -1 is not accepted for srclen.
    724725 *
     
    726727 **/
    727728size_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
    728                                 void const *src, size_t srclen, void *dst,
    729                                 BOOL allow_bad_conv)
     729                            void const *src, size_t srclen, void *dst,
     730                            BOOL allow_bad_conv)
    730731{
    731732        void **dest = (void **)dst;
     
    745746        size_t size;
    746747        smb_ucs2_t *buffer;
    747 
     748       
    748749        size = push_ucs2_allocate(&buffer, src);
    749750        if (size == (size_t)-1) {
     
    754755                return srclen;
    755756        }
    756 
     757       
    757758        size = convert_string(CH_UTF16LE, CH_UNIX, buffer, size, dest, destlen, True);
    758759        free(buffer);
     
    797798
    798799                strupper_w(buffer);
    799 
     800       
    800801                size = convert_string(CH_UTF16LE, CH_UNIX, buffer, -1, out_buffer, sizeof(out_buffer), True);
    801802                if (size == (size_t)-1) {
     
    811812        size_t size;
    812813        smb_ucs2_t *buffer = NULL;
    813 
     814       
    814815        size = convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, src, srclen,
    815                                            (void **)(void *)&buffer, True);
     816                                       (void **)(void *)&buffer, True);
    816817        if (size == (size_t)-1 || !buffer) {
    817818                smb_panic("failed to create UCS2 buffer");
     
    835836        smb_ucs2_t *buffer = NULL;
    836837        char *out_buffer;
    837 
     838       
    838839        size = push_ucs2_allocate(&buffer, s);
    839840        if (size == -1 || !buffer) {
     
    842843
    843844        strlower_w(buffer);
    844 
     845       
    845846        size = pull_ucs2_allocate(&out_buffer, buffer);
    846847        SAFE_FREE(buffer);
     
    849850                return NULL;
    850851        }
    851 
     852       
    852853        return out_buffer;
    853854}
     
    879880        size_t src_len = strlen(src);
    880881        pstring tmpbuf;
    881         size_t ret;
    882 
    883         /* No longer allow a length of -1 */
    884                 if (dest_len == (size_t)-1)
    885                 smb_panic("push_ascii - dest_len == -1");
     882        size_t ret;
     883
     884        /* No longer allow a length of -1 */
     885        if (dest_len == (size_t)-1)
     886                smb_panic("push_ascii - dest_len == -1");
    886887
    887888        if (flags & STR_UPPER) {
     
    894895                src_len++;
    895896
    896         ret =convert_string(CH_UNIX, CH_DOS, src, src_len, dest, dest_len, True);
    897         if (ret == (size_t)-1 &&
    898                         (flags & (STR_TERMINATE | STR_TERMINATE_ASCII))
    899                         && dest_len > 0) {
    900                 ((char *)dest)[0] = '\0';
    901         }
    902         return ret;
    903 
     897        ret =convert_string(CH_UNIX, CH_DOS, src, src_len, dest, dest_len, True);
     898        if (ret == (size_t)-1 &&
     899                        (flags & (STR_TERMINATE | STR_TERMINATE_ASCII))
     900                        && dest_len > 0) {
     901                ((char *)dest)[0] = '\0';
     902        }
     903        return ret;
    904904}
    905905
     
    10301030 * <dl>
    10311031 * <dt>STR_TERMINATE <dd>means include the null termination.
    1032  * <dt>STR_UPPER        <dd>means uppercase in the destination.
     1032 * <dt>STR_UPPER    <dd>means uppercase in the destination.
    10331033 * <dt>STR_NOALIGN   <dd>means don't do alignment.
    10341034 * </dl>
     
    10941094 * allocating a buffer using talloc().
    10951095 *
    1096  * @param dest always set at least to NULL
     1096 * @param dest always set at least to NULL 
    10971097 *
    10981098 * @returns The number of bytes occupied by the string in the destination
    1099  *              or -1 in case of error.
     1099 *        or -1 in case of error.
    11001100 **/
    11011101size_t push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src)
     
    11111111 * Copy a string from a unix char* src to a UCS2 destination, allocating a buffer
    11121112 *
    1113  * @param dest always set at least to NULL
     1113 * @param dest always set at least to NULL 
    11141114 *
    11151115 * @returns The number of bytes occupied by the string in the destination
    1116  *              or -1 in case of error.
     1116 *        or -1 in case of error.
    11171117 **/
    11181118
     
    11301130 Flags can have:
    11311131  STR_TERMINATE means include the null termination
    1132   STR_UPPER      means uppercase in the destination
     1132  STR_UPPER    means uppercase in the destination
    11331133 dest_len is the maximum length allowed in the destination. If dest_len
    11341134 is -1 then no maxiumum is used.
     
    11641164 * Copy a string from a unix char* src to a UTF-8 destination, allocating a buffer using talloc
    11651165 *
    1166  * @param dest always set at least to NULL
     1166 * @param dest always set at least to NULL 
    11671167 *
    11681168 * @returns The number of bytes occupied by the string in the destination
     
    11801180 * Copy a string from a unix char* src to a UTF-8 destination, allocating a buffer
    11811181 *
    1182  * @param dest always set at least to NULL
     1182 * @param dest always set at least to NULL 
    11831183 *
    11841184 * @returns The number of bytes occupied by the string in the destination
     
    11901190
    11911191        *dest = NULL;
    1192         return convert_string_allocate(NULL, CH_UNIX, CH_UTF8, src, src_len, (void **)dest, True);
     1192        return convert_string_allocate(NULL, CH_UNIX, CH_UTF8, src, src_len, (void **)dest, True);     
    11931193}
    11941194
     
    12311231        if (src_len != (size_t)-1)
    12321232                src_len &= ~1;
    1233 
     1233       
    12341234        ret = convert_string(CH_UTF16LE, CH_UNIX, src, src_len, dest, dest_len, True);
    12351235        if (ret == (size_t)-1) {
     
    12391239        if (src_len == (size_t)-1)
    12401240                src_len = ret*2;
    1241 
     1241               
    12421242        if (dest_len && ret) {
    12431243                /* Did we already process the terminating zero ? */
     
    12651265 * Copy a string from a UCS2 src to a unix char * destination, allocating a buffer using talloc
    12661266 *
    1267  * @param dest always set at least to NULL
     1267 * @param dest always set at least to NULL 
    12681268 *
    12691269 * @returns The number of bytes occupied by the string in the destination
     
    12801280 * Copy a string from a UCS2 src to a unix char * destination, allocating a buffer
    12811281 *
    1282  * @param dest always set at least to NULL
     1282 * @param dest always set at least to NULL 
    12831283 *
    12841284 * @returns The number of bytes occupied by the string in the destination
     
    12951295 * Copy a string from a UTF-8 src to a unix char * destination, allocating a buffer using talloc
    12961296 *
    1297  * @param dest always set at least to NULL
     1297 * @param dest always set at least to NULL 
    12981298 *
    12991299 * @returns The number of bytes occupied by the string in the destination
     
    13101310 * Copy a string from a UTF-8 src to a unix char * destination, allocating a buffer
    13111311 *
    1312  * @param dest always set at least to NULL
     1312 * @param dest always set at least to NULL 
    13131313 *
    13141314 * @returns The number of bytes occupied by the string in the destination
     
    13211321        return convert_string_allocate(NULL, CH_UTF8, CH_UNIX, src, src_len, (void **)dest, True);
    13221322}
    1323 
     1323 
    13241324/**
    13251325 * Copy a string from a DOS src to a unix char * destination, allocating a buffer using talloc
    13261326 *
    1327  * @param dest always set at least to NULL
     1327 * @param dest always set at least to NULL 
    13281328 *
    13291329 * @returns The number of bytes occupied by the string in the destination
     
    13391339/**
    13401340 Copy a string from a char* src to a unicode or ascii
    1341  dos codepage destination choosing unicode or ascii based on the
     1341 dos codepage destination choosing unicode or ascii based on the 
    13421342 flags in the SMB buffer starting at base_ptr.
    13431343 Return the number of bytes occupied by the string in the destination.
    13441344 flags can have:
    13451345  STR_TERMINATE means include the null termination.
    1346   STR_UPPER      means uppercase in the destination.
    1347   STR_ASCII      use ascii even with unicode packet.
     1346  STR_UPPER    means uppercase in the destination.
     1347  STR_ASCII    use ascii even with unicode packet.
    13481348  STR_NOALIGN   means don't do alignment.
    13491349 dest_len is the maximum length allowed in the destination. If dest_len
     
    13701370
    13711371        if (!(flags & STR_ASCII) && \
    1372                 ((flags & STR_UNICODE || \
    1373                   (SVAL(base_ptr, smb_flg2) & FLAGS2_UNICODE_STRINGS)))) {
     1372            ((flags & STR_UNICODE || \
     1373              (SVAL(base_ptr, smb_flg2) & FLAGS2_UNICODE_STRINGS)))) {
    13741374                return push_ucs2(base_ptr, dest, src, dest_len, flags);
    13751375        }
     
    13841384  STR_TERMINATE means the string in src is null terminated.
    13851385  STR_UNICODE   means to force as unicode.
    1386   STR_ASCII      use ascii even with unicode packet.
     1386  STR_ASCII    use ascii even with unicode packet.
    13871387  STR_NOALIGN   means don't do alignment.
    13881388 if STR_TERMINATE is set then src_len is ignored is it is -1
     
    14001400
    14011401        if (!(flags & STR_ASCII) && \
    1402                 ((flags & STR_UNICODE || \
    1403                   (SVAL(base_ptr, smb_flg2) & FLAGS2_UNICODE_STRINGS)))) {
     1402            ((flags & STR_UNICODE || \
     1403              (SVAL(base_ptr, smb_flg2) & FLAGS2_UNICODE_STRINGS)))) {
    14041404                return pull_ucs2(base_ptr, dest, src, dest_len, src_len, flags);
    14051405        }
     
    14101410{
    14111411        if (!(flags & STR_ASCII) && \
    1412                 ((flags & STR_UNICODE || \
    1413                   (SVAL(base_ptr, smb_flg2) & FLAGS2_UNICODE_STRINGS)))) {
     1412            ((flags & STR_UNICODE || \
     1413              (SVAL(base_ptr, smb_flg2) & FLAGS2_UNICODE_STRINGS)))) {
    14141414                return ucs2_align(base_ptr, p, flags);
    14151415        }
     
    14341434#ifdef __OS2__
    14351435        size_t ilen_max;
     1436        size_t olen_orig;
     1437        const char *inbuf;
    14361438#endif
    14371439        size_t ilen_orig;
    14381440        size_t ilen;
    1439         size_t olen_orig;
    14401441        size_t olen;
    1441         const char *inbuf;
     1442
    14421443        char *outbuf;
    14431444
     
    14911492                                break;
    14921493
     1494
    14931495                        case EINVAL :
    14941496#ifndef __OS2__
  • branches/samba-3.0/source/lib/debug.c

    r124 r165  
    693693         *  loop check do a new check as root.
    694694         */
     695
    695696        if( geteuid() != 0 )
    696697                return;
     
    715716                }
    716717        }
     718
    717719        /*
    718720         * Here's where we need to panic if dbf == NULL..
  • branches/samba-3.0/source/lib/events.c

    r1 r165  
    6565        DEBUG(10, ("Destroying timed event %lx \"%s\"\n", (unsigned long)te,
    6666                te->event_name));
    67         DLIST_REMOVE(te->event_ctx->timed_events, te);
     67        if (te->event_ctx) {
     68                DLIST_REMOVE(te->event_ctx->timed_events, te);
     69        }
    6870        return 0;
    6971}
     
    135137        struct event_context *event_ctx = fde->event_ctx;
    136138
    137         DLIST_REMOVE(event_ctx->fd_events, fde);
     139        if (event_ctx) {
     140                DLIST_REMOVE(event_ctx->fd_events, fde);
     141        }
    138142        return 0;
    139143}
     
    298302}
    299303
     304static int event_context_destructor(struct event_context *ev)
     305{
     306        while (ev->fd_events != NULL) {
     307                ev->fd_events->event_ctx = NULL;
     308                DLIST_REMOVE(ev->fd_events, ev->fd_events);
     309        }
     310        while (ev->timed_events != NULL) {
     311                ev->timed_events->event_ctx = NULL;
     312                DLIST_REMOVE(ev->timed_events, ev->timed_events);
     313        }
     314        return 0;
     315}
     316
     317void event_context_reinit(struct event_context *ev)
     318{
     319        event_context_destructor(ev);
     320        return;
     321}
     322
    300323struct event_context *event_context_init(TALLOC_CTX *mem_ctx)
    301324{
    302         return TALLOC_ZERO_P(NULL, struct event_context);
    303 }
    304 
    305 int set_event_dispatch_time(struct event_context *event_ctx,
    306                             const char *event_name, struct timeval when)
    307 {
    308         struct timed_event *te;
    309 
    310         for (te = event_ctx->timed_events; te; te = te->next) {
    311                 if (strcmp(event_name, te->event_name) == 0) {
    312                         DLIST_REMOVE(event_ctx->timed_events, te);
    313                         te->when = when;
    314                         add_event_by_time(te);
    315                         return 1;
    316                 }
    317         }
    318         return 0;
    319 }
    320 
    321 /* Returns 1 if event was found and cancelled, 0 otherwise. */
    322 
    323 int cancel_named_event(struct event_context *event_ctx,
    324                        const char *event_name)
    325 {
    326         struct timed_event *te;
    327 
    328         for (te = event_ctx->timed_events; te; te = te->next) {
    329                 if (strcmp(event_name, te->event_name) == 0) {
    330                         TALLOC_FREE(te);
    331                         return 1;
    332                 }
    333         }
    334         return 0;
    335 }
     325        struct event_context *result;
     326
     327        result = TALLOC_ZERO_P(mem_ctx, struct event_context);
     328        if (result == NULL) {
     329                return NULL;
     330        }
     331
     332        talloc_set_destructor(result, event_context_destructor);
     333        return result;
     334}
  • branches/samba-3.0/source/lib/genrand.c

    r1 r165  
    2929static void (*reseed_callback)(int *newseed);
    3030
    31 
    3231/****************************************************************
    3332 Copy any user given reseed data.
  • branches/samba-3.0/source/lib/iconv.c

    r62 r165  
    187187        }
    188188
     189
    189190        /* otherwise we have to do it chunks at a time */
    190191        while (*inbytesleft > 0) {
  • branches/samba-3.0/source/lib/interfaces.c

    r1 r165  
    8383#include "interfaces.h"
    8484
    85 #ifdef HAVE_IFACE_IFCONF
     85#if HAVE_IFACE_IFCONF
    8686
    8787/* this works for Linux 2.2, Solaris 2.5, SunOS4, HPUX 10.20, OSF1
  • branches/samba-3.0/source/lib/messages.c

    r62 r165  
    128128                       0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
    129129                       O_RDWR|O_CREAT,0600);
     130
    130131        if (!tdb) {
    131132                DEBUG(0,("ERROR: Failed to initialise messages database\n"));
  • branches/samba-3.0/source/lib/replace/autoconf-2.60.m4

    r39 r165  
    180180# Enable extensions on systems that normally disable them,
    181181# typically due to standards-conformance issues.
     182m4_ifndef([AC_USE_SYSTEM_EXTENSIONS],[
    182183AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
    183184[
     
    209210  AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
    210211])
     212])
  • branches/samba-3.0/source/lib/select.c

    r33 r165  
    2929   This means all Samba signal handlers should call sys_select_signal().
    3030*/
     31
    3132static pid_t initialised;
    3233static int select_pipe[2];
     
    9596        errno = 0;
    9697        ret = select(maxfd,readfds2,writefds,errorfds,tval);
     98
    9799        if (ret <= 0) {
    98100                FD_ZERO(readfds2);
  • branches/samba-3.0/source/lib/util.c

    r105 r165  
    19921992        SMB_STRUCT_FLOCK lock;
    19931993        int ret;
     1994
     1995        DEBUG(8,("fcntl_lock fd=%d op=%d offset=%.0f count=%.0f type=%d\n",
     1996                fd,op,(double)offset,(double)count,type));
    19941997
    19951998        lock.l_type = type;
     
    33353338        return talloc_named_const(context, size, name);
    33363339}
     3340
     3341bool reinit_after_fork(struct messaging_context *msg_ctx,
     3342                       struct event_context *ev_ctx,
     3343                       bool parent_longlived)
     3344{
     3345        set_need_random_reseed();
     3346        if (tdb_reopen_all(parent_longlived ? 1 : 0) == -1) {
     3347                DEBUG(0, ("tdb_reopen_all failed.\n"));
     3348                return false;
     3349        }
     3350        event_context_reinit(ev_ctx);
     3351        return true;
     3352}
  • branches/samba-3.0/source/lib/util_sock.c

    r161 r165  
    155155  {"TCP_KEEPINTVL",     IPPROTO_TCP,   TCP_KEEPINTVL,   0,                 OPT_INT},
    156156#endif
    157 #if defined(IPTOS_LOWDELAY) && !defined(TCPV40HDRS)
     157#ifdef IPTOS_LOWDELAY
    158158  {"IPTOS_LOWDELAY",    IPPROTO_IP,    IP_TOS,          IPTOS_LOWDELAY,    OPT_ON},
    159159#endif
    160 #if defined(IPTOS_THROUGHPUT) && !defined(TCPV40HDRS)
     160#ifdef IPTOS_THROUGHPUT
    161161  {"IPTOS_THROUGHPUT",  IPPROTO_IP,    IP_TOS,          IPTOS_THROUGHPUT,  OPT_ON},
    162162#endif
  • branches/samba-3.0/source/lib/util_tdb.c

    r134 r165  
    8282                tdb_setalarm_sigptr(tdb, NULL);
    8383                CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
    84                 if (gotalarm) {
     84                if (gotalarm && (ret == -1)) {
    8585                        DEBUG(0,("tdb_chainlock_with_timeout_internal: alarm (%u) timed out for key %s in tdb %s\n",
    8686                                timeout, key.dptr, tdb_name(tdb)));
Note: See TracChangeset for help on using the changeset viewer.