Commit Graph

42 Commits (46d5d4e48f7f25563a8c5897ebeb88e7f262f943)

Author SHA1 Message Date
Xavier Leroy dc043a7b62 PR#6945 and GPR#227: protect Sys and Unix functions against string arguments containing the null character '\000'
Implementation notes:
- Based on c-cube's GPR#227 code, but many Unix functions were missing.
- For Unix.bind and Unix.connect to a PF_UNIX address, tolerate
  file names whose first character is '\000': in Linux, these have
  a meaning as "abstract socket addresses", and in other operating
  systems, the resulting empty path name causes a EINVAL error
  (tested under MacOS X).
- Very lightly tested.
- win32unix remains to be fixed.
2015-11-11 17:07:44 +01:00
Damien Doligez 659615c7b1 fix PR#7003 and a few other bugs caused by misuse of Int_val
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16525 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-19 15:47:33 +00:00
Damien Doligez e60a2db81c PR#6521: {Bytes,Char,String}.escaped are locale-dependent
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15901 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-03-11 18:41:15 +00:00
Gabriel Scherer 7ca29ef3f7 PR#5887: move the byterun/*.h headers to byterun/caml/*.h to avoid header name clashes
(Jérôme Vouillon and Adrien Nader and Peter Zotov)


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15757 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-12-27 14:41:49 +00:00
Damien Doligez 1cb0b23a08 Start tidying up the runtime:
- document most of the "size" and "length" parameters and global variables,
  specifying bytes or words. Change some of them from bytes to words.
- start getting rid of "char *" and use sensible types instead.
- other small changes


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15647 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-12-12 15:18:04 +00:00
Xavier Leroy b868c05ec9 PR#6517: use ISO C99 types {,u}int{32,64}_t in preference to our homegrown
types {,u}int{32,64}.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15131 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-08-27 09:58:33 +00:00
Damien Doligez cbfe627f92 merge changes from branch 4.02 from branching (rev 14852) to 4.02.0+rc1 (rev 15121)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15125 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-08-22 13:45:02 +00:00
Xavier Leroy 774e30e138 PR#6075: avoid using unsafe C library functions (strcpy, strcat, sprintf).
An ISO C99-compliant C compiler and standard library is now assumed.
(Plus special exceptions for MSVC.)  In particular, emulation code for
64-bit integer arithmetic was removed, the C compiler must support a
64-bit integer type.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14607 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-04-15 17:09:13 +00:00
Gabriel Scherer 9e17f24967 bound checking bug with caml_string_{get,set}{16,32,64}: fix the runtime C code
As notified by Nicolas Trangez, the following program behaves in an
unexpected way by returning 0 instead of failing with an out-of-bound
exception:

  external get16 : string -> int -> int = "%caml_string_get16"
  let test = get16 "" 0

caml_string_get16(str, idx) will access indices (idx) and (idx+1). The
bound-checking code is currently implemented as:

   if (idx < 0 || idx >= caml_string_length(str) - 1) caml_array_bound_error();

This is wrong as caml_string_length returns an mlsize_t which is
unsigned, so substracting 1 gets buggy when the size is 0. The test
should be written as follow:

   if (idx < 0 || idx + 1 >= caml_string_length(str)) caml_array_bound_error();

Note 1: we can exploit this bug to make out-of-bound access to
a string, but I think get16 examples will run into the padding
characters of OCaml strings and behave in a not-too-wrong way. It may
also be the case of get32, but get64 will access 7 bytes, so access
memory outside the string:

  # external set64: string -> int -> int -> unit = "%caml_string_get64";;
  external set64 : string -> int -> int -> unit = "%caml_string_get64"
  # set64 "" 0 0;;
  Segmentation fault

Note 2: this first commit only fixes the C code in byterun/str.c. Only
ocamlc actually uses these functions when the compiler primitive is
used ("%caml_string_get16" instead of "caml_string_get16"). ocamlopt
generates ocaml code directly, and this part has yet to be fixed in
a following commit.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14267 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-11-05 11:09:29 +00:00
Alain Frisch ff4e0a81f8 #5774: fix MSVC port.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13141 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-12-19 16:22:30 +00:00
Fabrice Le Fessant ec7ac9cb3d PR#5771: Add primitives for reading 2, 4, 8 bytes in strings and bigarrays
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13087 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-11-09 16:15:29 +00:00
Damien Doligez def31744f9 remove all $Id keywords
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13013 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-15 17:50:56 +00:00
Damien Doligez 3b507dd1aa renaming of Objective Caml to OCaml and cleanup of copyright headers
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11156 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-27 14:17:02 +00:00
Damien Doligez 04b1656222 clean up spaces and tabs
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9547 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-01-22 12:48:24 +00:00
Xavier Leroy 1baa43a304 Added shortcut if == to caml_string_compare and caml_string_equal
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7819 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2007-01-30 09:52:08 +00:00
Xavier Leroy 3de54dec26 Remplacement long/unsigned long par intnat/uintnat
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7064 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2005-09-22 14:21:50 +00:00
Damien Doligez db3745919b suppression des warnings "unused variable" de gcc
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6299 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-05-17 17:10:00 +00:00
Damien Doligez 0c7aecb88d depollution suite (et fin?) (PR#1914 et PR#1956)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6047 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-01-02 19:23:29 +00:00
Damien Doligez 5a678d29f5 depollution suite (PR#1914 et PR#1956)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6045 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-01-01 16:42:43 +00:00
Damien Doligez 31943bac1d depollution suite (PR#1914 et PR#1956); byterun/weak.c: PR#1929 suite
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6041 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-12-29 22:15:02 +00:00
Damien Doligez aa46693dc5 depollution (PR#1914, PR#1956)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6023 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-12-16 18:09:44 +00:00
Xavier Leroy d71d293491 Les acces hors bornes dans les tableaux et les chaines levent tous la meme exception Invalid_arg("index out of bounds") pour compatibilite avec ocamlopt
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5950 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-11-21 15:55:24 +00:00
Xavier Leroy 4a19edd532 Bug dans string_{less,greater}{than,equal} (PR#1674)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5541 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-05-06 13:52:08 +00:00
Xavier Leroy 5c7accd134 Optimisation de Pervasives.compare par strength reduction
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5474 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-04-01 08:46:39 +00:00
Xavier Leroy dde21583f7 Suppression du cas particulier Win32, on peut utiliser setlocale()
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4930 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-06-18 13:00:13 +00:00
Xavier Leroy 7501784c80 MAJ en-tetes pour mentionner la 'special exception' sur la LGPL
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4144 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-12-07 13:41:02 +00:00
Xavier Leroy ddd99c7e5d Chargement dynamique de primitives C
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3677 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-08-28 14:47:48 +00:00
Damien Doligez cdf19e15fc bcopy -> memmove; pas de virgule finale dans instruct.h
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3310 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2000-10-12 18:05:42 +00:00
Xavier Leroy cc0f32b054 Changement de la licence
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2553 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1999-11-17 18:59:06 +00:00
Xavier Leroy 2c5ab3494a Utiliser isprint() plutot que notre emulation faiblarde
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2366 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1999-05-15 15:08:11 +00:00
Xavier Leroy af85f7c394 Portage Cray T3E
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1996 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1998-06-23 16:47:02 +00:00
Xavier Leroy 1517cea772 Sources C convertis en ANSI C
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1696 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-09-02 12:55:01 +00:00
Damien Doligez c4fb76de04 Fix: bug dans le calcul de la longueur max d'une chaine.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1616 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-06-16 17:07:11 +00:00
Xavier Leroy 2301d778e7 Renommage en Objective Caml
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@782 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1996-04-30 14:53:58 +00:00
Xavier Leroy 4a3f111a02 Suppression de l'instruction TRANSLATE.
Ajout d'un test de debordement dans SWITCH.
Ajout de la primitive de test d'un bit dans une chaine.
Rectif. des declarations de signals.h


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@737 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1996-04-04 15:56:26 +00:00
Xavier Leroy 84ffb16ed7 Debut du portage Windows NT/95
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@636 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1996-02-15 16:19:09 +00:00
Xavier Leroy e4066357b1 Ajout des notices de copyright
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@195 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-08-09 15:06:35 +00:00
Xavier Leroy e8c57efb59 Ajout de l'instruction C_CALL5.
meta.c eclate en obj.c et meta.c.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@82 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-07-11 18:07:22 +00:00
Xavier Leroy c226d5efeb Branchement du GC de la version bytecode sur le compilateur natif
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@72 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-07-10 09:48:27 +00:00
Xavier Leroy e0f3c043e5 Changement representation des constructeurs constants.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@40 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-06-18 14:44:56 +00:00
Xavier Leroy 00f1ca9d88 Introduction de primitives C pour {Array,String}.{get,set}
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@30 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-06-15 08:09:30 +00:00
Xavier Leroy 61bd8ace6b Passage a la version bootstrappee (franchissement du Rubicon)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-05-04 10:15:53 +00:00