s3-prefork: Improve error detection when handling new connections
[amitay/samba.git] / source3 / web / neg_lang.c
index 82411000cd1e8d806e8d98cb2b634d6a19ed2f2d..59475d12b57ccb4299ea44a042a0156f67b51f92 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "includes.h"
 #include "web/swat_proto.h"
+#include "intl/lang_tdb.h"
 
 /*
   during a file download we first check to see if there is a language
@@ -32,8 +33,7 @@ int web_open(const char *fname, int flags, mode_t mode)
        char *lang = lang_tdb_current();
        int fd;
        if (lang) {
-               asprintf(&p, "lang/%s/%s", lang, fname);
-               if (p) {
+               if (asprintf(&p, "lang/%s/%s", lang, fname) != -1) {
                        fd = sys_open(p, flags, mode);
                        free(p);
                        if (fd != -1) {
@@ -52,9 +52,8 @@ struct pri_list {
        char *string;
 };
 
-static int qsort_cmp_list(const void *x, const void *y) {
-       struct pri_list *a = (struct pri_list *)x;
-       struct pri_list *b = (struct pri_list *)y;
+static int qsort_cmp_list(struct pri_list *a, struct pri_list *b)
+{
        if (a->pri > b->pri) return -1;
        if (a->pri < b->pri) return 1;
        return 0;
@@ -74,7 +73,7 @@ void web_set_lang(const char *lang_string)
        int lang_num, i;
 
        /* build the lang list */
-       lang_list = str_list_make(talloc_tos(), lang_string, ", \t\r\n");
+       lang_list = str_list_make_v3(talloc_tos(), lang_string, ", \t\r\n");
        if (!lang_list) return;
        
        /* sort the list by priority */
@@ -102,7 +101,7 @@ void web_set_lang(const char *lang_string)
        }
        TALLOC_FREE(lang_list);
 
-       qsort(pl, lang_num, sizeof(struct pri_list), &qsort_cmp_list);
+       TYPESAFE_QSORT(pl, lang_num, qsort_cmp_list);
 
        /* it's not an error to not initialise - we just fall back to 
           the default */