1.. title:: clang-tidy - cert-err34-c 2 3cert-err34-c 4============ 5 6This check flags calls to string-to-number conversion functions that do not 7verify the validity of the conversion, such as ``atoi()`` or ``scanf()``. It 8does not flag calls to ``strtol()``, or other, related conversion functions that 9do perform better error checking. 10 11.. code-block:: c 12 13 #include <stdlib.h> 14 15 void func(const char *buff) { 16 int si; 17 18 if (buff) { 19 si = atoi(buff); /* 'atoi' used to convert a string to an integer, but function will 20 not report conversion errors; consider using 'strtol' instead. */ 21 } else { 22 /* Handle error */ 23 } 24 } 25 26This check corresponds to the CERT C Coding Standard rule 27`ERR34-C. Detect errors when converting a string to a number 28<https://www.securecoding.cert.org/confluence/display/c/ERR34-C.+Detect+errors+when+converting+a+string+to+a+number>`_. 29